From f7d1c59c224f81a8bab5fa2afcaf815988f50467 Mon Sep 17 00:00:00 2001 From: Peter Fales Date: Tue, 25 Mar 2008 22:44:01 +0100 Subject: [PATCH] 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. --- src/id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/id.c b/src/id.c index 9ee52e1..a178714 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 (); -- 2.7.4