libsepol: use logging framework in ebitmap.c

Use the internal logging framework instead of directly writing to
stdout as it might be undesired to do so within a library.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
Christian Göttsche 2021-12-09 17:48:59 +01:00 committed by James Carter
parent 5c178f9f55
commit 852f14d43d

View File

@ -406,8 +406,7 @@ int ebitmap_read(ebitmap_t * e, void *fp)
count = le32_to_cpu(buf[2]);
if (mapsize != MAPSIZE) {
printf
("security: ebitmap: map size %d does not match my size %zu (high bit was %d)\n",
ERR(NULL, "security: ebitmap: map size %d does not match my size %zu (high bit was %d)\n",
mapsize, MAPSIZE, e->highbit);
goto bad;
}
@ -416,8 +415,7 @@ int ebitmap_read(ebitmap_t * e, void *fp)
goto ok;
}
if (e->highbit & (MAPSIZE - 1)) {
printf
("security: ebitmap: high bit (%d) is not a multiple of the map size (%zu)\n",
ERR(NULL, "security: ebitmap: high bit (%d) is not a multiple of the map size (%zu)\n",
e->highbit, MAPSIZE);
goto bad;
}
@ -429,12 +427,12 @@ int ebitmap_read(ebitmap_t * e, void *fp)
for (i = 0; i < count; i++) {
rc = next_entry(buf, fp, sizeof(uint32_t));
if (rc < 0) {
printf("security: ebitmap: truncated map\n");
ERR(NULL, "security: ebitmap: truncated map\n");
goto bad;
}
n = (ebitmap_node_t *) malloc(sizeof(ebitmap_node_t));
if (!n) {
printf("security: ebitmap: out of memory\n");
ERR(NULL, "security: ebitmap: out of memory\n");
rc = -ENOMEM;
goto bad;
}
@ -443,34 +441,30 @@ int ebitmap_read(ebitmap_t * e, void *fp)
n->startbit = le32_to_cpu(buf[0]);
if (n->startbit & (MAPSIZE - 1)) {
printf
("security: ebitmap start bit (%d) is not a multiple of the map size (%zu)\n",
ERR(NULL, "security: ebitmap start bit (%d) is not a multiple of the map size (%zu)\n",
n->startbit, MAPSIZE);
goto bad_free;
}
if (n->startbit > (e->highbit - MAPSIZE)) {
printf
("security: ebitmap start bit (%d) is beyond the end of the bitmap (%zu)\n",
ERR(NULL, "security: ebitmap start bit (%d) is beyond the end of the bitmap (%zu)\n",
n->startbit, (e->highbit - MAPSIZE));
goto bad_free;
}
rc = next_entry(&map, fp, sizeof(uint64_t));
if (rc < 0) {
printf("security: ebitmap: truncated map\n");
ERR(NULL, "security: ebitmap: truncated map\n");
goto bad_free;
}
n->map = le64_to_cpu(map);
if (!n->map) {
printf
("security: ebitmap: null map in ebitmap (startbit %d)\n",
ERR(NULL, "security: ebitmap: null map in ebitmap (startbit %d)\n",
n->startbit);
goto bad_free;
}
if (l) {
if (n->startbit <= l->startbit) {
printf
("security: ebitmap: start bit %d comes after start bit %d\n",
ERR(NULL, "security: ebitmap: start bit %d comes after start bit %d\n",
n->startbit, l->startbit);
goto bad_free;
}
@ -481,8 +475,7 @@ int ebitmap_read(ebitmap_t * e, void *fp)
l = n;
}
if (count && l->startbit + MAPSIZE != e->highbit) {
printf
("security: ebitmap: high bit %u has not the expected value %zu\n",
ERR(NULL, "security: ebitmap: high bit %u has not the expected value %zu\n",
e->highbit, l->startbit + MAPSIZE);
goto bad;
}