chroot: fix supplemental group lookup with --userspec=UID

* src/chroot.c (main): Copy pwd->pw_name as it can be overwritten.
* NEWS: Mention the fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-C8RRA4R8.
This commit is contained in:
Pádraig Brady committed 2026-11-06 23:54:53 +00:00
1 parent 37f04509c9
commit bc177b4275
2 files changed
+6 -4

No files matched your search

+3 -3
View File
@@ -15,9 +15,9 @@ GNU coreutils NEWS -*- outline -*-
when only a partial context is specified.
[bug introduced with the chcon program in coreutils-6.9.90]
'chroot --userspec=USER' now uses the primary group of USER as looked up
inside the chroot. Previously the group looked up outside the chroot
was used, even when the look-up inside the chroot succeeded.
'chroot --userspec=USER' now uses the primary group of USER from inside the
chroot. Also this no longer sets supplemental groups of an unrelated user,
or reads freed memory, when the USER ID is only known outside the chroot.
[bug introduced in coreutils-8.23]
'cksum' now detects GNU and BSD reversed formats for each checksum file.
+3 -1
View File
@@ -315,7 +315,9 @@ main (int argc, char **argv)
gid = pwd->pw_gid;
gid_inferred = true;
}
username = pwd->pw_name;
/* Copy, as the look-up inside the chroot reuses PWD's
storage, even when it fails. */
username = xstrdup (pwd->pw_name);
}
}