From: Peter Fales Date: Tue, 25 Mar 2008 21:44:01 +0000 (+0100) Subject: id bug fix: don't point to potentially clobbered static storage X-Git-Tag: v6.11~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7d1c59c224f81a8bab5fa2afcaf815988f50467;p=thirdparty%2Fcoreutils.git id bug fix: don't point to potentially clobbered static storage On at least Mac OS, when calling getpwuid twice with the same UID, the static storage containing results from the first call is invalidated by the second call. * src/id.c (main): Point to a copy of the user name string. --- diff --git a/src/id.c b/src/id.c index 9ee52e1fcb..a178714fd6 100644 --- a/src/id.c +++ b/src/id.c @@ -211,7 +211,7 @@ of a different user")); struct passwd const *pwd; euid = geteuid (); pwd = getpwuid (euid); - user_name = pwd ? pwd->pw_name : NULL; + user_name = pwd ? xstrdup (pwd->pw_name) : NULL; ruid = getuid (); egid = getegid (); rgid = getgid ();