aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--iconv/Makefile6
-rw-r--r--iconv/gconv_parseconfdir.h8
-rwxr-xr-xiconv/tst-iconvconfig.sh48
-rw-r--r--stdio-common/Makefile24
-rw-r--r--stdio-common/tst-freopen4-main.c44
5 files changed, 97 insertions, 33 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/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
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 64b3575..ae2b90c 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -759,6 +759,30 @@ CFLAGS-tst-scanf-binary-gnu89.c += -std=gnu89 -DOBJPFX=\"$(objpfx)\"
CPPFLAGS += $(libio-mtsafe)
+make-tst-freopen4-out = \
+ $(run-program-prefix-before-env) \
+ $(run-program-env) \
+ MALLOC_TRACE=$(@:.out=.mtrace) \
+ LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so \
+ $(run-program-prefix-after-env) $<
+
+freopen4-temp-dir-before = warning: could not remove temporary file:
+freopen4-temp-dir-after = : No such file or directory
+
+$(objpfx)tst-freopen4.out: $(objpfx)tst-freopen4
+ $(make-tst-freopen4-out) > $@ && \
+ grep "$(freopen4-temp-dir-before)" $@ \
+ | sed -e "s/$(freopen4-temp-dir-before)//; s/$(freopen4-temp-dir-after)//" \
+ | xargs rm -rf; \
+ $(evaluate-test)
+
+$(objpfx)tst-freopen64-4.out: $(objpfx)tst-freopen64-4
+ $(make-tst-freopen4-out) > $@ && \
+ grep "$(freopen4-temp-dir-before)" $@ \
+ | sed -e "s/$(freopen4-temp-dir-before)//; s/$(freopen4-temp-dir-after)//" \
+ | xargs rm -rf; \
+ $(evaluate-test)
+
$(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
$(test-program-cmd) > $@ 2>&1; \
$(evaluate-test)
diff --git a/stdio-common/tst-freopen4-main.c b/stdio-common/tst-freopen4-main.c
index 436da4d..3336f53 100644
--- a/stdio-common/tst-freopen4-main.c
+++ b/stdio-common/tst-freopen4-main.c
@@ -28,15 +28,25 @@
#include <support/test-driver.h>
#include <support/xstdio.h>
#include <support/xunistd.h>
-#include <support/capture_subprocess.h>
-static void
-do_test_chroot (void *data)
+int
+do_test (void)
{
- char *temp_dir = (char *) data;
+ mtrace ();
+ char *temp_dir;
FILE *fp;
int ret;
+ /* These chroot tests verify that either reopening a renamed or
+ deleted file works even in the absence of /proc, or that it fails
+ (without memory leaks); thus, for example, such reopening does
+ not crash in the absence of /proc. */
+
+ support_become_root ();
+ if (!support_can_chroot ())
+ return EXIT_UNSUPPORTED;
+
+ temp_dir = support_create_temp_directory ("tst-freopen4");
xchroot (temp_dir);
/* Test freopen with NULL, renamed file. This verifies that
@@ -86,32 +96,6 @@ do_test_chroot (void *data)
puts ("freopen of deleted file failed (OK)");
free (temp_dir);
-}
-
-int
-do_test (void)
-{
- mtrace ();
- char *temp_dir;
-
- /* These chroot tests verify that either reopening a renamed or
- deleted file works even in the absence of /proc, or that it fails
- (without memory leaks); thus, for example, such reopening does
- not crash in the absence of /proc. */
-
- support_become_root ();
- if (!support_can_chroot ())
- return EXIT_UNSUPPORTED;
-
- temp_dir = support_create_temp_directory ("tst-freopen4");
-
- struct support_capture_subprocess result;
- result = support_capture_subprocess (do_test_chroot, temp_dir);
- support_capture_subprocess_check (&result, "freopen4", 0,
- sc_allow_stdout);
- fputs (result.out.buffer, stdout);
- support_capture_subprocess_free (&result);
-
return 0;
}