summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-02-04 14:27:41 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2022-02-04 14:28:25 -0800
commitff208d546a26fee39a0191297c11560da74b5dee (patch)
tree529916c7a56aa3032e88c2f0bc1c9ac3c0491da1 /lib
parent6ef3d783333346333f35bb181ba90f5bc46c0b29 (diff)
downloadgnulib-ff208d546a26fee39a0191297c11560da74b5dee.tar.gz
userspec: help fix GNU ‘id’ incompatibility
* lib/userspec.c (parse_with_separator): Don’t set *username to a numeric string that is not a user name, and similarly for *groupname. Needed to fix Bug#53631.
Diffstat (limited to 'lib')
-rw-r--r--lib/userspec.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/userspec.c b/lib/userspec.c
index 99ac93bb53..f05ccbe635 100644
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -161,6 +161,7 @@ parse_with_separator (char const *spec, char const *separator,
pwd = (*u == '+' ? NULL : getpwnam (u));
if (pwd == NULL)
{
+ username = NULL;
bool use_login_group = (separator != NULL && g == NULL);
if (use_login_group)
{
@@ -202,6 +203,7 @@ parse_with_separator (char const *spec, char const *separator,
grp = (*g == '+' ? NULL : getgrnam (g));
if (grp == NULL)
{
+ groupname = NULL;
unsigned long int tmp;
if (xstrtoul (g, NULL, 10, &tmp, "") == LONGINT_OK
&& tmp <= MAXGID && (gid_t) tmp != (gid_t) -1)