The read_data function returns the number of bytes written, not a boolean,
so fix the error checking so we exit if fewer than expected bytes were
read. Thanks to Agostino Sarubbo of Gentoo for providing a bug report with
a reproducible test case.
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
zck_log(ZCK_LOG_DEBUG, "Reading the rest of the header: %llu bytes",
(long long unsigned) zck->header_length);
if(loaded < zck->header_length) {
- if(!read_data(zck, header + loaded, zck->header_length - loaded))
+ if(read_data(zck, header + loaded, zck->header_length - loaded) < zck->header_length - loaded) {
+ set_fatal_error(zck, "Unable to read %llu bytes from the file", zck->header_length - loaded);
return false;
+ }
zck->header_size = zck->lead_size + zck->header_length;
}