ebitmap: detect invalid bitmap

When count is 0 and the highbit is not zero, the ebitmap is not
valid and the internal node is not allocated. This causes issues
when routines, like mls_context_isvalid() attempt to use the
ebitmap_for_each_bit() and ebitmap_node_get_bit() as they assume
a highbit > 0 will have a node allocated.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
This commit is contained in:
William Roberts 2016-08-16 10:28:33 -07:00 committed by James Carter
parent b612314bf3
commit 33de30a284

View File

@ -394,6 +394,10 @@ int ebitmap_read(ebitmap_t * e, void *fp)
e->highbit, MAPSIZE);
goto bad;
}
if (e->highbit && !count)
goto bad;
l = NULL;
for (i = 0; i < count; i++) {
rc = next_entry(buf, fp, sizeof(uint32_t));