Forcibly set the current seek location of gz files that we are accessing

via dup(fileno());gzdopen() because stdio might have buffered data from
the underlying file meaning that the underlying seek position isn't what
we think it is.
This commit is contained in:
Lloyd Parkes 2022-10-16 12:36:00 +13:00
parent fcf742837e
commit 635aa2a3fc
1 changed files with 1 additions and 0 deletions

View File

@ -4272,6 +4272,7 @@ int fstReaderInit(struct fstReaderContext *xc)
#endif #endif
zfd = dup(fileno(xc->f)); zfd = dup(fileno(xc->f));
lseek(zfd, ftell(xc->f), SEEK_SET);
zhandle = gzdopen(zfd, "rb"); zhandle = gzdopen(zfd, "rb");
if (zhandle) { if (zhandle) {
for (offpnt = 0; offpnt < uclen; offpnt += FST_GZIO_LEN) { for (offpnt = 0; offpnt < uclen; offpnt += FST_GZIO_LEN) {