mirror of
https://github.com/SELinuxProject/selinux
synced 2025-04-20 22:35:19 +00:00
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:
parent
5c178f9f55
commit
852f14d43d
@ -406,8 +406,7 @@ int ebitmap_read(ebitmap_t * e, void *fp)
|
|||||||
count = le32_to_cpu(buf[2]);
|
count = le32_to_cpu(buf[2]);
|
||||||
|
|
||||||
if (mapsize != MAPSIZE) {
|
if (mapsize != MAPSIZE) {
|
||||||
printf
|
ERR(NULL, "security: ebitmap: map size %d does not match my size %zu (high bit was %d)\n",
|
||||||
("security: ebitmap: map size %d does not match my size %zu (high bit was %d)\n",
|
|
||||||
mapsize, MAPSIZE, e->highbit);
|
mapsize, MAPSIZE, e->highbit);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@ -416,8 +415,7 @@ int ebitmap_read(ebitmap_t * e, void *fp)
|
|||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
if (e->highbit & (MAPSIZE - 1)) {
|
if (e->highbit & (MAPSIZE - 1)) {
|
||||||
printf
|
ERR(NULL, "security: ebitmap: high bit (%d) is not a multiple of the map size (%zu)\n",
|
||||||
("security: ebitmap: high bit (%d) is not a multiple of the map size (%zu)\n",
|
|
||||||
e->highbit, MAPSIZE);
|
e->highbit, MAPSIZE);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@ -429,12 +427,12 @@ int ebitmap_read(ebitmap_t * e, void *fp)
|
|||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
rc = next_entry(buf, fp, sizeof(uint32_t));
|
rc = next_entry(buf, fp, sizeof(uint32_t));
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
printf("security: ebitmap: truncated map\n");
|
ERR(NULL, "security: ebitmap: truncated map\n");
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
n = (ebitmap_node_t *) malloc(sizeof(ebitmap_node_t));
|
n = (ebitmap_node_t *) malloc(sizeof(ebitmap_node_t));
|
||||||
if (!n) {
|
if (!n) {
|
||||||
printf("security: ebitmap: out of memory\n");
|
ERR(NULL, "security: ebitmap: out of memory\n");
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@ -443,34 +441,30 @@ int ebitmap_read(ebitmap_t * e, void *fp)
|
|||||||
n->startbit = le32_to_cpu(buf[0]);
|
n->startbit = le32_to_cpu(buf[0]);
|
||||||
|
|
||||||
if (n->startbit & (MAPSIZE - 1)) {
|
if (n->startbit & (MAPSIZE - 1)) {
|
||||||
printf
|
ERR(NULL, "security: ebitmap start bit (%d) is not a multiple of the map size (%zu)\n",
|
||||||
("security: ebitmap start bit (%d) is not a multiple of the map size (%zu)\n",
|
|
||||||
n->startbit, MAPSIZE);
|
n->startbit, MAPSIZE);
|
||||||
goto bad_free;
|
goto bad_free;
|
||||||
}
|
}
|
||||||
if (n->startbit > (e->highbit - MAPSIZE)) {
|
if (n->startbit > (e->highbit - MAPSIZE)) {
|
||||||
printf
|
ERR(NULL, "security: ebitmap start bit (%d) is beyond the end of the bitmap (%zu)\n",
|
||||||
("security: ebitmap start bit (%d) is beyond the end of the bitmap (%zu)\n",
|
|
||||||
n->startbit, (e->highbit - MAPSIZE));
|
n->startbit, (e->highbit - MAPSIZE));
|
||||||
goto bad_free;
|
goto bad_free;
|
||||||
}
|
}
|
||||||
rc = next_entry(&map, fp, sizeof(uint64_t));
|
rc = next_entry(&map, fp, sizeof(uint64_t));
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
printf("security: ebitmap: truncated map\n");
|
ERR(NULL, "security: ebitmap: truncated map\n");
|
||||||
goto bad_free;
|
goto bad_free;
|
||||||
}
|
}
|
||||||
n->map = le64_to_cpu(map);
|
n->map = le64_to_cpu(map);
|
||||||
|
|
||||||
if (!n->map) {
|
if (!n->map) {
|
||||||
printf
|
ERR(NULL, "security: ebitmap: null map in ebitmap (startbit %d)\n",
|
||||||
("security: ebitmap: null map in ebitmap (startbit %d)\n",
|
|
||||||
n->startbit);
|
n->startbit);
|
||||||
goto bad_free;
|
goto bad_free;
|
||||||
}
|
}
|
||||||
if (l) {
|
if (l) {
|
||||||
if (n->startbit <= l->startbit) {
|
if (n->startbit <= l->startbit) {
|
||||||
printf
|
ERR(NULL, "security: ebitmap: start bit %d comes after start bit %d\n",
|
||||||
("security: ebitmap: start bit %d comes after start bit %d\n",
|
|
||||||
n->startbit, l->startbit);
|
n->startbit, l->startbit);
|
||||||
goto bad_free;
|
goto bad_free;
|
||||||
}
|
}
|
||||||
@ -481,8 +475,7 @@ int ebitmap_read(ebitmap_t * e, void *fp)
|
|||||||
l = n;
|
l = n;
|
||||||
}
|
}
|
||||||
if (count && l->startbit + MAPSIZE != e->highbit) {
|
if (count && l->startbit + MAPSIZE != e->highbit) {
|
||||||
printf
|
ERR(NULL, "security: ebitmap: high bit %u has not the expected value %zu\n",
|
||||||
("security: ebitmap: high bit %u has not the expected value %zu\n",
|
|
||||||
e->highbit, l->startbit + MAPSIZE);
|
e->highbit, l->startbit + MAPSIZE);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user