]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
iconv: iconv -o should not create executable files (bug 33164)
authorFlorian Weimer <fweimer@redhat.com>
Thu, 17 Jul 2025 12:44:05 +0000 (14:44 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 24 Jul 2025 07:53:50 +0000 (09:53 +0200)
The mistake is that open must use 0666 to pick up the umask,
and not 0777 (which is required by mkdir).

Fixes commit 8ef3cff9d1ceafe369f982d980678d749fb93bd2
("iconv: Support in-place conversions (bug 10460, bug 32033)").

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit cdcf24ee14c27b77744ff52ab3ae852821207eb0)

NEWS
iconv/iconv_prog.c
iconv/tst-iconv_prog-buffer.sh

diff --git a/NEWS b/NEWS
index 947db1c14426deca558db581f33bb6c56ee02ad8..89d0935bebf46fdae65cbdafb6260066dfa453ff 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,7 @@ The following bugs were resolved with this release:
   [32981] ports: elf/tst-execstack-prog-static-tunable fails on
     sparc64-linux-gnu
   [32987] elf: Fix subprocess status handling for tst-dlopen-sgid
+  [33164] iconv -o should not create executable files
   [33185] Fix double-free after allocation failure in regcomp
 \f
 Version 2.41
index 7dba5d8dff7dad3ec94bd5460588ee3578d06455..558cfb11a3ecb3261d948f893b0372e6d283fd1d 100644 (file)
@@ -436,7 +436,7 @@ input_error (const char *path)
 static void
 open_output_direct (void)
 {
-  output_fd = open64 (output_file, O_WRONLY | O_CREAT | O_TRUNC, 0777);
+  output_fd = open64 (output_file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
   if (output_fd < 0)
     output_error ();
 }
@@ -457,7 +457,7 @@ prepare_output_file (char **argv)
   else
     {
       /* If iconv creates the output file, no overlap is possible.  */
-      output_fd = open64 (output_file, O_WRONLY | O_CREAT | O_EXCL, 0777);
+      output_fd = open64 (output_file, O_WRONLY | O_CREAT | O_EXCL, 0666);
       if (output_fd >= 0)
        output_buffer_size = copy_buffer_size;
       else
index 1c499d590de51b5aaef94bf1568d109bd7e4479d..40340c38fa7f7d1834c7de8d2735f85395f59a0c 100644 (file)
@@ -75,6 +75,10 @@ run_iconv () {
 }
 
 check_out_expected () {
+    if test -x "$tmp/out" ; then
+       echo "error: iconv output file is executable"
+       failure=true
+    fi
     if ! cmp -s "$tmp/out" "$tmp/expected" ; then
         echo "error: iconv output difference" >&$logfd
         echo "*** expected ***" >&$logfd