]> Savannah Git Hosting - gnulib.git/commitdiff
userspec: help fix GNU ‘id’ incompatibility
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 4 Feb 2022 22:27:41 +0000 (14:27 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 4 Feb 2022 22:28:25 +0000 (14:28 -0800)
* 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.

ChangeLog
lib/userspec.c

index a202950bd94469fefb0c15dc4384f337f0f946b6..5445802ea2b88ec04d7284d56b85fd0ce60eecd4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-02-04  Paul Eggert  <eggert@cs.ucla.edu>
+
+       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.
+
 2022-01-30  Pádraig Brady  <P@draigBrady.com>
 
        argmatch: add variants that only match full argument
index 99ac93bb5311c09d026af609f7d98f9e12dc67e0..f05ccbe63545e8c367151111739439ec84386156 100644 (file)
@@ -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)