]> git.seodisparate.com - SimpleArchiver/commitdiff
Set umask on compression-temp-file
authorStephen Seo <seo.disparate@gmail.com>
Wed, 26 Feb 2025 09:42:45 +0000 (18:42 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Wed, 26 Feb 2025 09:42:45 +0000 (18:42 +0900)
Previous behavior created temp files (for compression) with default
permissions. This commit uses umask to keep only permissions for the
user and deny permissions to others (and restores the umask after
creation of the temp file).

src/helpers.c

index 9ec87c24b64fb6362b29595cb1e6111cdfb4d2a4..e4b5921a9195a2bafc1e8301bfccbcd9a4f85ef8 100644 (file)
@@ -905,7 +905,9 @@ FILE *simple_archiver_helper_temp_dir(const SDArchiverParsed *parsed,
     }
   } while (1);
 
+  mode_t prev_umask = umask(S_IRWXG | S_IRWXO);
   FILE *temp_file = fopen(temp_filename, "w+b");
+  umask(prev_umask);
 
   if (temp_file) {
     if (out_temp_filename) {