libsemanage: check for rewind(3) failure
Use fseek(3) instead of rewind(3) to detect failures. Reported-by: clang-analyzer Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
48f66b6aaa
commit
c76b273855
|
@ -114,7 +114,12 @@ static ssize_t bunzip(semanage_handle_t *sh, FILE *f, void **data)
|
||||||
|
|
||||||
/* Check if the file is bzipped */
|
/* Check if the file is bzipped */
|
||||||
bzerror = fread(buf, 1, BZ2_MAGICLEN, f);
|
bzerror = fread(buf, 1, BZ2_MAGICLEN, f);
|
||||||
rewind(f);
|
|
||||||
|
if (fseek(f, 0L, SEEK_SET) == -1) {
|
||||||
|
ERR(sh, "Failure rewinding file.");
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
if ((bzerror != BZ2_MAGICLEN) || memcmp(buf, BZ2_MAGICSTR, BZ2_MAGICLEN)) {
|
if ((bzerror != BZ2_MAGICLEN) || memcmp(buf, BZ2_MAGICSTR, BZ2_MAGICLEN)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue