fix-file-permissions-on-compression
authorDebian Med Packaging Team <debian-med-packaging@lists.alioth.debian.org>
Mon, 1 Feb 2021 19:36:53 +0000 (19:36 +0000)
committerÉtienne Mollier <etienne.mollier@mailoo.org>
Mon, 1 Feb 2021 19:36:53 +0000 (19:36 +0000)
Gbp-Pq: Name fix-file-permissions-on-compression.patch

programs/fileio.c

index 9fb795ed3f27bbfbb9b45e6f1087112449060c56..5202ccb43c6b8d11080547d9667fa7a7a2328731 100644 (file)
@@ -482,8 +482,14 @@ static FILE* FIO_openDstFile(const char* srcFileName, const char* dstFileName)
     }   }
 
     {   FILE* const f = fopen( dstFileName, "wb" );
-        if (f == NULL)
+        if (f == NULL) {
             DISPLAYLEVEL(1, "zstd: %s: %s\n", dstFileName, strerror(errno));
+        } else if (srcFileName != NULL
+                   && strcmp (srcFileName, stdinmark)
+                   && strcmp(dstFileName, nulmark) ) {
+                /* reduce rights on newly created dst file while compression is ongoing */
+            chmod(dstFileName, 00600);
+        }
         return f;
     }
 }