[PATCH] iconv: iconv -o should not create executable files (bug 33164)
Andreas K. Huettel
andreas.huettel@ur.de
Thu Jul 17 12:36:49 GMT 2025
OK, simple enough. What Adhemerval says.
Am Donnerstag, 17. Juli 2025, 00:07:14 Mitteleuropäische Sommerzeit schrieb Florian Weimer:
> 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)").
>
> ---
> iconv/iconv_prog.c | 4 ++--
> iconv/tst-iconv_prog-buffer.sh | 4 ++++
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c
> index 7dba5d8dff..558cfb11a3 100644
> --- a/iconv/iconv_prog.c
> +++ b/iconv/iconv_prog.c
> @@ -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
> diff --git a/iconv/tst-iconv_prog-buffer.sh b/iconv/tst-iconv_prog-buffer.sh
> index 1c499d590d..40340c38fa 100644
> --- a/iconv/tst-iconv_prog-buffer.sh
> +++ b/iconv/tst-iconv_prog-buffer.sh
> @@ -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
>
> base-commit: 0263528f8dd60cf58976e2d516b7c9edb16ae6f8
>
>
--
PD Dr. Andreas K. Huettel
Institute for Experimental and Applied Physics
University of Regensburg
93040 Regensburg
Germany
tel. +49 151 241 67748 (mobile)
tel. +49 941 943 1618 (office)
e-mail andreas.huettel@ur.de
https://www.akhuettel.de/
https://www.akhuettel.de/group/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 981 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250717/2c68d673/attachment.sig>
More information about the Libc-alpha
mailing list