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.
<attila at stalphonsos dot com> 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.
-/* $OpenBSD: dbm.c,v 1.1 2016/08/01 10:32:39 schwarze Exp $ */
+/* $OpenBSD: dbm.c,v 1.2 2016/08/30 21:58:59 schwarze Exp $ */
/*
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
*
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;
}
default:
abort();
}
- ip = 0;
+ if (cp == NULL) {
+ iteration = ITER_NONE;
+ match = NULL;
+ cp = NULL;
+ ip = npages;
+ } else
+ ip = 0;
return res;
}