Message ID | 20241018151300.445618-3-cgoettsche@seltendoof.de (mailing list archive) |
---|---|
State | Accepted |
Commit | c76b27385591 |
Headers | show |
Series | [1/4] libselinux: avoid errno modification by fclose(3) | expand |
diff --git a/libsemanage/src/compressed_file.c b/libsemanage/src/compressed_file.c index 5546b830..e230a70b 100644 --- a/libsemanage/src/compressed_file.c +++ b/libsemanage/src/compressed_file.c @@ -114,7 +114,12 @@ static ssize_t bunzip(semanage_handle_t *sh, FILE *f, void **data) /* Check if the file is bzipped */ 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)) { goto exit; }