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:
Christian Göttsche 2024-10-18 17:12:59 +02:00 committed by James Carter
parent 48f66b6aaa
commit c76b273855
1 changed files with 6 additions and 1 deletions

View File

@ -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;
} }