Index: stand/libsa/bzipfs.c =================================================================== --- stand/libsa/bzipfs.c +++ stand/libsa/bzipfs.c @@ -340,6 +340,9 @@ 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); Index: stand/libsa/gzipfs.c =================================================================== --- stand/libsa/gzipfs.c +++ stand/libsa/gzipfs.c @@ -315,6 +315,9 @@ 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);