From: Nick Terrell Date: Tue, 17 Jul 2018 21:57:27 +0000 (-0700) Subject: fileio: Error in compression on read errors X-Git-Tag: v0.0.29~66^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e706d7f2cb79df257809b45c033b3bcf5822edf;p=thirdparty%2Fzstd.git fileio: Error in compression on read errors We can write a corrupted file if the input file errors during a read. We should return a non-zero error code in this case. --- diff --git a/programs/fileio.c b/programs/fileio.c index b4eed28d1..85367fdfc 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -797,6 +797,14 @@ FIO_compressZstdFrame(const cRess_t* ressPtr, } } while (directive != ZSTD_e_end); + if (ferror(srcFile)) { + EXM_THROW(26, "Read error : I/O error"); + } + if (fileSize != UTIL_FILESIZE_UNKNOWN && *readsize != fileSize) { + EXM_THROW(27, "Read error : Incomplete read : %llu / %llu B", + (unsigned long long)*readsize, (unsigned long long)fileSize); + } + return compressedfilesize; }