]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix small file passthrough (#3215)
authorChris Burgess <9002722+cgbur@users.noreply.github.com>
Fri, 29 Jul 2022 19:22:46 +0000 (15:22 -0400)
committerGitHub <noreply@github.com>
Fri, 29 Jul 2022 19:22:46 +0000 (12:22 -0700)
programs/fileio.c
tests/playTests.sh

index a83b8064a9d3f563c19dc0c0d2833182ee4a6fc4..7a479069a0729d8d27e50c15f751e049acc89d5a 100644 (file)
@@ -2346,7 +2346,10 @@ static int FIO_decompressFrames(FIO_ctx_t* const fCtx,
             break;   /* no more input */
         }
         readSomething = 1;   /* there is at least 1 byte in srcFile */
-        if (ress.readCtx->srcBufferLoaded < toRead) {
+        if (ress.readCtx->srcBufferLoaded < toRead) { /* not enough input to check magic number */
+            if ((prefs->overwrite) && !strcmp (dstFileName, stdoutmark)) {  /* pass-through mode */
+                return FIO_passThrough(&ress);
+            }
             DISPLAYLEVEL(1, "zstd: %s: unknown header \n", srcFileName);
             return 1;
         }
index 0e2b0fbb2bfa140db8b3ffd7f7710be2cdd4ec31..7c111e7a3e6a2a82defa0726a88cf5b8e0370e8f 100755 (executable)
@@ -808,6 +808,16 @@ println "Hello world 1!" | zstd -df
 println "Hello world 2!" | zstd -dcf
 println "Hello world 3!" > tmp1
 zstd -dcf tmp1
+println "" | zstd -df > tmp1
+println "" > tmp2
+$DIFF -q tmp1 tmp2
+println "1" | zstd -df > tmp1
+println "1" > tmp2
+$DIFF -q tmp1 tmp2
+println "12" | zstd -df > tmp1
+println "12" > tmp2
+$DIFF -q tmp1 tmp2
+rm -rf tmp*
 
 
 println "\n===>  frame concatenation "