[review,v3] Use getpwuid_r instead of getpwuid

Message ID 20191111193531.9DB8020AF6@gnutoolchain-gerrit.osci.io
State New
Headers show
Series
  • [review,v3] Use getpwuid_r instead of getpwuid
Related show

Commit Message

Sourceware to Gerrit sync (Code Review) Nov. 11, 2019, 7:35 p.m.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/485
......................................................................

Use getpwuid_r instead of getpwuid

gdb/ChangeLog:

2019-11-11  Christian Biesinger  <cbiesinger@google.com>

	* nat/linux-osdata.c (user_from_uid): Use getpwuid_r.

Change-Id: I587359267f8963ef1da6ba0223a1525807a721de
---
M gdb/nat/linux-osdata.c
1 file changed, 4 insertions(+), 1 deletion(-)




-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I587359267f8963ef1da6ba0223a1525807a721de
Gerrit-Change-Number: 485
Gerrit-PatchSet: 3
Gerrit-Owner: Christian Biesinger <cbiesinger@google.com>
Gerrit-CC: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newpatchset

Patch

diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
index 84357e2..ca6acd3 100644
--- a/gdb/nat/linux-osdata.c
+++ b/gdb/nat/linux-osdata.c
@@ -205,7 +205,10 @@ 
 static void
 user_from_uid (char *user, int maxlen, uid_t uid)
 {
-  struct passwd *pwentry = getpwuid (uid);
+  struct passwd *pwentry;
+  char buf[1024];
+  struct passwd pwd;
+  getpwuid_r (uid, &pwd, buf, sizeof (buf), &pwentry);
 
   if (pwentry)
     {