libsa: Fix infinite loop in bzipfs & gzipfs
A bug in the loader's bzipfs & gzipfs filesystems caused compressed kernel and modules not to work on EFI systems with a veriexec-enabled loader. Since the size of files in these filesystems are not known _a priori_ `stat` would initialize the size to -1 and the loader would then hang in an infinite loop while trying to seek (read) to the end of file since the loop termination condition compares the current offset to that negative target position. Reviewers: vangyzen, imp, Bret Ketchum (Bret.Ketchum@dell.com) Differential Revision: https://reviews.freebsd.org/D30414 Sponsored by: Dell EMC Isilon MFC to: stable/12, stable/13 MFC after: 1 week
This commit is contained in:
parent
33764e3fd0
commit
3df4c387d2
@ -340,6 +340,9 @@ bzf_seek(struct open_file *f, off_t offset, int where)
|
||||
target - bzf->bzf_bzstream.total_out_lo32), NULL);
|
||||
if (errno)
|
||||
return(-1);
|
||||
/* Break out of loop if end of file has been reached. */
|
||||
if (bzf->bzf_endseen)
|
||||
break;
|
||||
}
|
||||
/* This is where we are (be honest if we overshot) */
|
||||
return(bzf->bzf_bzstream.total_out_lo32);
|
||||
|
@ -315,6 +315,9 @@ zf_seek(struct open_file *f, off_t offset, int where)
|
||||
target - zf->zf_zstream.total_out), NULL);
|
||||
if (errno)
|
||||
return(-1);
|
||||
/* Break out of loop if end of file has been reached. */
|
||||
if (zf->zf_endseen)
|
||||
break;
|
||||
}
|
||||
/* This is where we are (be honest if we overshot) */
|
||||
return(zf->zf_zstream.total_out);
|
||||
|
Loading…
Reference in New Issue
Block a user