]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
iconv: Multiple - on command line should not fail (bug 32050)
authorFlorian Weimer <fweimer@redhat.com>
Fri, 20 Sep 2024 11:10:54 +0000 (13:10 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 20 Sep 2024 11:51:09 +0000 (13:51 +0200)
Usually, the second and subsequent - return EOF immediately
and do not contribute to the output, but this is not an error.

Reviewed-by: DJ Delorie <dj@redhat.com>
iconv/iconv_prog.c
iconv/tst-iconv_prog-buffer.sh

index 3e02db7319185d45a7b04cd4225d610ff521a8f0..dd4bc3a59a20799a1171b1592729ec57b7d2ce54 100644 (file)
@@ -287,7 +287,8 @@ conversions from `%s' and to `%s' are not supported"),
                ret = process_fd (cd, fd);
 
                /* Now close the file.  */
-               close (fd);
+               if (fd != STDIN_FILENO)
+                 close (fd);
 
                if (ret != 0)
                  {
index 54ff871d32929997a6fe917a0f5f27b4817da785..a9c3729d948b467953efb62e2b8dca0913a69701 100644 (file)
@@ -265,6 +265,11 @@ expect_exit 1 run_iconv -o "$tmp/out" "$tmp/abc" "$tmp/0xff" "$tmp/def"
 expect_exit 1 run_iconv -o "$tmp/out" "$tmp/abc" - < "$tmp/0xff" "$tmp/def"
 ! test -e "$tmp/out"
 
+# Listing standard input multiple times should not fail (bug 32050).
+
+run_iconv -o "$tmp/out" "$tmp/xy" - - "$tmp/zt" < "$tmp/abc"
+expect_files xy abc zt
+
 if $failure ; then
     exit 1
 fi