aboutsummaryrefslogtreecommitdiff
path: root/iconv
diff options
context:
space:
mode:
Diffstat (limited to 'iconv')
-rw-r--r--iconv/Makefile6
-rw-r--r--iconv/gconv_parseconfdir.h8
-rw-r--r--iconv/gconv_simple.c8
-rw-r--r--iconv/iconv_prog.c4
-rw-r--r--iconv/tst-iconv_prog-buffer.sh4
-rwxr-xr-xiconv/tst-iconvconfig.sh48
6 files changed, 69 insertions, 9 deletions
diff --git a/iconv/Makefile b/iconv/Makefile
index 9a94a41..672126d 100644
--- a/iconv/Makefile
+++ b/iconv/Makefile
@@ -85,6 +85,7 @@ tests-special += \
$(objpfx)tst-iconv_prog-buffer-tiny.out \
$(objpfx)tst-iconv_prog-buffer.out \
$(objpfx)tst-iconv_prog.out \
+ $(objpfx)tst-iconvconfig.out \
$(objpfx)tst-translit-mchar.out \
# tests-special
endif
@@ -164,3 +165,8 @@ $(objpfx)tst-iconv_prog-buffer-large.out: \
tst-iconv_prog-buffer.sh $(objpfx)iconv_prog
$(BASH) $< $(common-objdir) '$(run-program-prefix)' '' '22' > $@; \
$(evaluate-test)
+
+$(objpfx)tst-iconvconfig.out: tst-iconvconfig.sh $(objpfx)iconvconfig
+ $(BASH) $< $(common-objdir) '$(test-wrapper-env)' \
+ '$(run-program-env)' > $@; \
+ $(evaluate-test)
diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h
index a7ebfd8..31f8f1c 100644
--- a/iconv/gconv_parseconfdir.h
+++ b/iconv/gconv_parseconfdir.h
@@ -33,9 +33,10 @@
# define closedir __closedir
# define mempcpy __mempcpy
# define struct_stat64 struct __stat64_t64
-# define lstat64 __lstat64_time64
+# define stat64_impl __stat64_time64
# define feof_unlocked __feof_unlocked
#else
+# define stat64_impl stat64
# define struct_stat64 struct stat64
#endif
@@ -151,7 +152,8 @@ gconv_parseconfdir (const char *prefix, const char *dir, size_t dir_len)
struct dirent64 *ent;
while ((ent = readdir64 (confdir)) != NULL)
{
- if (ent->d_type != DT_REG && ent->d_type != DT_UNKNOWN)
+ if (ent->d_type != DT_REG && ent->d_type != DT_UNKNOWN
+ && ent->d_type != DT_LNK)
continue;
size_t len = strlen (ent->d_name);
@@ -166,7 +168,7 @@ gconv_parseconfdir (const char *prefix, const char *dir, size_t dir_len)
continue;
if (ent->d_type != DT_UNKNOWN
- || (lstat64 (conf, &st) != -1 && S_ISREG (st.st_mode)))
+ || (stat64_impl (conf, &st) != -1 && S_ISREG (st.st_mode)))
found |= read_conf_file (conf, dir, dir_len);
free (conf);
diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c
index 1e29eb1..0ebdcce 100644
--- a/iconv/gconv_simple.c
+++ b/iconv/gconv_simple.c
@@ -90,7 +90,7 @@ internal_ucs4_loop (struct __gconv_step *step,
for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4, outptr += 4)
{
uint32_t val = get32 (inptr);
- put32 (outptr, __builtin_bswap32 (val));
+ put32 (outptr, bswap_32 (val));
}
*inptrp = inptr;
@@ -196,7 +196,7 @@ ucs4_internal_loop (struct __gconv_step *step,
{
uint32_t inval = get32 (inptr);
#if __BYTE_ORDER == __LITTLE_ENDIAN
- inval = __builtin_bswap32 (inval);
+ inval = bswap_32 (inval);
#endif
if (__glibc_unlikely (inval > 0x7fffffff))
@@ -337,7 +337,7 @@ internal_ucs4le_loop (struct __gconv_step *step,
for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4, outptr += 4)
{
uint32_t val = get32 (inptr);
- put32 (outptr, __builtin_bswap32 (val));
+ put32 (outptr, bswap_32 (val));
}
*inptrp = inptr;
@@ -442,7 +442,7 @@ ucs4le_internal_loop (struct __gconv_step *step,
{
uint32_t inval = get32 (inptr);
#if __BYTE_ORDER == __BIG_ENDIAN
- inval = __builtin_bswap32 (inval);
+ inval = bswap_32 (inval);
#endif
if (__glibc_unlikely (inval > 0x7fffffff))
diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c
index 7dba5d8..558cfb1 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 1c499d5..40340c3 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
diff --git a/iconv/tst-iconvconfig.sh b/iconv/tst-iconvconfig.sh
new file mode 100755
index 0000000..0b16b17
--- /dev/null
+++ b/iconv/tst-iconvconfig.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# Check if iconvconfig correctly handle config links (BZ 32339)
+# Copyright (C) 2025 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <https://www.gnu.org/licenses/>.
+
+set -e
+
+build_dir=$1
+test_wrapper_env="$2"
+run_program_env="$3"
+
+# We have to have some directories in the library path.
+LIBPATH=$build_dir:$build_dir/iconvdata
+
+ICONVCONFIG="
+$build_dir/elf/ld.so --library-path $LIBPATH $build_dir/iconv/iconvconfig
+"
+
+ICONVCONFIG="$test_wrapper_env $run_program_env $ICONVCONFIG"
+
+TIMEOUTFACTOR=${TIMEOUTFACTOR:-1}
+
+tmpdir=$(mktemp -d $build_dir/iconv/tst-iconvconfig.XXXXXX)
+#trap 'rm -fr $tmpdir' 0 1 2 3 15 EXIT
+
+touch $tmpdir/gconv-modules-extra.conf
+mkdir $tmpdir/gconv-modules.d
+cd $tmpdir/gconv-modules.d && ln -s ../gconv-modules-extra.conf . && cd -
+
+$ICONVCONFIG --nostdlib $tmpdir -o $tmpdir/gconv-modules.cache
+
+[ ! -e $tmpdir/tmpdir/gconv-modules.cache ] || exit 1
+
+exit 0