From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 95D31385841B; Sat, 24 Feb 2024 12:13:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95D31385841B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1708776820; bh=GRwp/THHeEXekeIpUk7vvklvqWF8l0k9ixCkp8IGqPY=; h=From:To:Subject:Date:From; b=jfB8f+SCTcVGqspUh2X+lgDE5V/PXsQRqledGZVo6Md6zoEYNoZA5QA9zrwH5oFUT mOTStPNF2yMvKN+yZzgAjwVIJnajWjdNS1glzOfAhXDdWSIO0+lsuazhANjdAl9cUC 2eJkhaeyWHSSx7qoGW3NSYvJS92/Qao72DFunJag= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_5-branch] Cygwin: newgrp: fix invalid usage of argv X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/cygwin-3_5-branch X-Git-Oldrev: 83967aa244a88f54a38b4bce6aa7c25e48e6c87f X-Git-Newrev: 08df2e23a75190fced8c1a2446ebaee4f469eb96 Message-Id: <20240224121340.95D31385841B@sourceware.org> Date: Sat, 24 Feb 2024 12:13:37 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D08df2e23a75= 190fced8c1a2446ebaee4f469eb96 commit 08df2e23a75190fced8c1a2446ebaee4f469eb96 Author: Corinna Vinschen AuthorDate: Sat Feb 24 10:46:54 2024 +0100 Commit: Corinna Vinschen CommitDate: Sat Feb 24 13:12:37 2024 +0100 Cygwin: newgrp: fix invalid usage of argv =20 Fix an error message accessing argv[1] even after it has been potentially moved. Print group name from group DB instead. =20 Fixes: 8bd56ec873453 ("Cygwin: newgrp: first full version") Signed-off-by: Corinna Vinschen 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] =3D=3D NULL) { gid =3D pw->pw_gid; + gr =3D getgrgid (gid); } else { @@ -179,7 +180,7 @@ main (int argc, const char **argv) if (setgid (gid) !=3D 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; }