public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: newgrp: fix invalid usage of argv
@ 2024-02-24 12:14 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2024-02-24 12:14 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=808a95d24d6aff7191b4ba4710213f283c5e6379

commit 808a95d24d6aff7191b4ba4710213f283c5e6379
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Sat Feb 24 10:46:54 2024 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Sat Feb 24 13:08:33 2024 +0100

    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>

Diff:
---
 winsup/utils/newgrp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/winsup/utils/newgrp.c b/winsup/utils/newgrp.c
index 88586352e108..e312a3c51d38 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;
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-24 12:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-24 12:14 [newlib-cygwin/main] Cygwin: newgrp: fix invalid usage of argv Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).