mirror of
https://github.com/facebook/zstd.git
synced 2025-08-07 06:23:00 +03:00
fix the assertion in readLinesFromFile (#3084)
* fix the assertion in readLinesFromFile When the file is not terminated by endline, readLineFromFile will append a '\0' for the last line. In this case pos + lineLength == dstCapacity. * test: don't print very long text garbage
This commit is contained in:
@@ -418,7 +418,7 @@ readLinesFromFile(void* dst, size_t dstCapacity,
|
|||||||
while ( !feof(inputFile) ) {
|
while ( !feof(inputFile) ) {
|
||||||
size_t const lineLength = readLineFromFile(buf+pos, dstCapacity-pos, inputFile);
|
size_t const lineLength = readLineFromFile(buf+pos, dstCapacity-pos, inputFile);
|
||||||
if (lineLength == 0) break;
|
if (lineLength == 0) break;
|
||||||
assert(pos + lineLength < dstCapacity);
|
assert(pos + lineLength <= dstCapacity); /* '=' for inputFile not terminated with '\n' */
|
||||||
pos += lineLength;
|
pos += lineLength;
|
||||||
++nbFiles;
|
++nbFiles;
|
||||||
}
|
}
|
||||||
|
@@ -735,11 +735,11 @@ test -f tmp4
|
|||||||
|
|
||||||
println "test : survive the list of files with too long filenames (--filelist=FILE)"
|
println "test : survive the list of files with too long filenames (--filelist=FILE)"
|
||||||
datagen -g5M > tmp_badList
|
datagen -g5M > tmp_badList
|
||||||
zstd -f --filelist=tmp_badList && die "should have failed : file name length is too long"
|
zstd -qq -f --filelist=tmp_badList && die "should have failed : file name length is too long" # printing very long text garbage on console will cause CI failure
|
||||||
|
|
||||||
println "test : survive a list of files which is text garbage (--filelist=FILE)"
|
println "test : survive a list of files which is text garbage (--filelist=FILE)"
|
||||||
datagen > tmp_badList
|
datagen > tmp_badList
|
||||||
zstd -f --filelist=tmp_badList && die "should have failed : list is text garbage"
|
zstd -qq -f --filelist=tmp_badList && die "should have failed : list is text garbage" # printing very long text garbage on console will cause CI failure
|
||||||
|
|
||||||
println "test : survive a list of files which is binary garbage (--filelist=FILE)"
|
println "test : survive a list of files which is binary garbage (--filelist=FILE)"
|
||||||
datagen -P0 -g1M > tmp_badList
|
datagen -P0 -g1M > tmp_badList
|
||||||
|
Reference in New Issue
Block a user