From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 6c433146 for ; Tue, 30 Aug 2016 17:01:38 -0500 (EST) Date: Tue, 30 Aug 2016 17:01:38 -0500 (EST) Message-Id: <15930894204161614524.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: When the database is corrupt in the sense of containing invalid X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- When the database is corrupt in the sense of containing invalid pointers in the pages table, do not access NULL pointers, but gracefully handle the errors. Similar patches will be needed for the macro tables, too. audited the code and pointed out to me that dbm_get() can return NULL for corrupted databases, but that isn't handled properly at various places. Modified Files: -------------- mdocml: dbm.c Revision Data ------------- Index: dbm.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/dbm.c,v retrieving revision 1.3 retrieving revision 1.4 diff -Ldbm.c -Ldbm.c -u -p -r1.3 -r1.4 --- dbm.c +++ dbm.c @@ -150,10 +150,18 @@ dbm_page_get(int32_t ip) assert(ip >= 0); assert(ip < npages); res.name = dbm_get(pages[ip].name); + if (res.name == NULL) + res.name = "(NULL)"; res.sect = dbm_get(pages[ip].sect); + if (res.sect == NULL) + res.sect = "(NULL)"; res.arch = pages[ip].arch ? dbm_get(pages[ip].arch) : NULL; res.desc = dbm_get(pages[ip].desc); + if (res.desc == NULL) + res.desc = "(NULL)"; res.file = dbm_get(pages[ip].file); + if (res.file == NULL) + res.file = " (NULL)"; res.addr = dbm_addr(pages + ip); return &res; } @@ -250,7 +258,13 @@ page_bytitle(enum iter arg_iter, const s default: abort(); } - ip = 0; + if (cp == NULL) { + iteration = ITER_NONE; + match = NULL; + cp = NULL; + ip = npages; + } else + ip = 0; return res; } -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv