1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-25 02:02:09 +03:00

iconv: iconv -o should not create executable files (bug 33164)

The mistake is that open must use 0666 to pick up the umask,
and not 0777 (which is required by mkdir).

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

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
Florian Weimer
2025-07-17 14:44:05 +02:00
parent 0263528f8d
commit cdcf24ee14
2 changed files with 6 additions and 2 deletions

View 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

View 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