1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 11:16:16 +02:00

du,ls: don’t modify getenv strings

Fix du and ls to conform to the POSIX getenv spec,
which says you can’t modify strings returned by getenv
unless you put the string there directly, or used putenv.
This portability bug was found by strict C23 checking
using qualifier-generic functions.
* bootstrap.conf (gnulib_modules): Add xmemdup0.  Sort.
* src/du.c (main):
* src/ls.c (decode_switches):
Don’t modify the string that getenv returns.
Instead, use xmemdup0 if needed, and include xmemdup0.h.
This commit is contained in:
Paul Eggert
2025-11-23 11:42:57 -08:00
parent eade022f24
commit 2199c9003e
4 changed files with 53 additions and 36 deletions

View File

@@ -69,8 +69,8 @@ gnulib_modules="
crc-x86_64
crypto/md5
crypto/sha1
crypto/sha3
crypto/sha256
crypto/sha3
crypto/sha512
crypto/sm3
cycle-check
@@ -215,14 +215,14 @@ gnulib_modules="
pipe2
posix-shell
posix_spawn
posix_spawnattr_destroy
posix_spawnattr_init
posix_spawnattr_setflags
posix_spawnattr_setsigdefault
posix_spawn_file_actions_addclose
posix_spawn_file_actions_adddup2
posix_spawn_file_actions_destroy
posix_spawn_file_actions_init
posix_spawnattr_destroy
posix_spawnattr_init
posix_spawnattr_setflags
posix_spawnattr_setsigdefault
posix_spawnp
posixtm
posixver
@@ -325,6 +325,7 @@ gnulib_modules="
xgetgroups
xgethostname
xmemcoll
xmemdup0
xnanosleep
xprintf
xprintf-posix