]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed : null-length string roundtrip
authorYann Collet <yann.collet.73@gmail.com>
Tue, 10 May 2016 03:56:09 +0000 (05:56 +0200)
committerYann Collet <yann.collet.73@gmail.com>
Tue, 10 May 2016 03:56:09 +0000 (05:56 +0200)
programs/fileio.c
programs/playTests.sh

index 4bb451b956dfba9598ea259876f24c1d4eac2b12..36b1ff297d1f472764dec777ea7d6aa3edbd28e6 100644 (file)
@@ -535,10 +535,9 @@ unsigned long long FIO_decompressFrame(dRess_t ress,
 
     /* Complete Header loading */
     {   size_t const toLoad = ZSTD_frameHeaderSize_max - alreadyLoaded;   /* assumption : alreadyLoaded <= ZSTD_frameHeaderSize_max */
-        size_t const checkSize = fread(((char*)ress.srcBuffer) + alreadyLoaded, 1, toLoad, finput);
-        if (checkSize != toLoad) EXM_THROW(32, "Read error");   /* assumption : srcSize >= ZSTD_frameHeaderSize_max */
+        size_t const loadedSize = fread(((char*)ress.srcBuffer) + alreadyLoaded, 1, toLoad, finput);   /* can be <= toLoad (null string) */
+        readSize = alreadyLoaded + loadedSize;
     }
-    readSize = ZSTD_frameHeaderSize_max;
 
     /* Main decompression Loop */
     while (1) {
index 63e818443c07cd328e1b581073b4ea372c11095d..1c5f00a13729add6841b1059bdab571915e14d01 100755 (executable)
@@ -29,10 +29,11 @@ $ZSTD -f tmp                             # trivial compression case, creates tmp
 $ZSTD -df tmp.zst                        # trivial decompression case (overwrites tmp)
 echo "test : too large compression level (must fail)"
 $ZSTD -99 tmp && die "too large compression level undetected"
-echo "test : compress null-length file"
+echo "test : compress to stdout"
+$ZSTD tmp -c > tmpCompressed                 
+$ZSTD tmp --stdout > tmpCompressed       # long command format
+echo "test : null-length file roundtrip"
 echo -n '' | $ZSTD - --stdout | $ZSTD -d --stdout
-$ZSTD tmp -c > tmpCompressed             # compression using stdout     
-$ZSTD tmp --stdout > tmpCompressed       # compressoin using stdout, long format
 echo "test : decompress file with wrong suffix (must fail)"
 $ZSTD -d tmpCompressed && die "wrong suffix error not detected!"
 $ZSTD -d tmpCompressed -c > tmpResult    # decompression using stdout