diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2024-02-24 10:46:54 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2024-02-24 13:08:33 +0100 |
commit | 808a95d24d6aff7191b4ba4710213f283c5e6379 (patch) | |
tree | b5c9356dcef02bdbfb0e299dfe6248057abdede8 /winsup | |
parent | 3e16e86a569950fcddc3d6a55e54cdae00634d6e (diff) | |
download | newlib-808a95d24d6aff7191b4ba4710213f283c5e6379.zip newlib-808a95d24d6aff7191b4ba4710213f283c5e6379.tar.gz newlib-808a95d24d6aff7191b4ba4710213f283c5e6379.tar.bz2 |
Cygwin: newgrp: fix invalid usage of argv
Fix an error message accessing argv[1] even after it has been
potentially moved. Print group name from group DB instead.
Fixes: 8bd56ec873453 ("Cygwin: newgrp: first full version")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/utils/newgrp.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/winsup/utils/newgrp.c b/winsup/utils/newgrp.c index 8858635..e312a3c 100644 --- a/winsup/utils/newgrp.c +++ b/winsup/utils/newgrp.c @@ -160,6 +160,7 @@ main (int argc, const char **argv) if (argv[1] == NULL) { gid = pw->pw_gid; + gr = getgrgid (gid); } else { @@ -179,7 +180,7 @@ main (int argc, const char **argv) if (setgid (gid) != 0) { fprintf (stderr, "%s: can't switch primary group to '%s'\n", - program_invocation_short_name, argv[1]); + program_invocation_short_name, gr->gr_name); return 2; } |