Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [review] Use getpwuid_r instead of getpwuid when available
@ 2019-11-02 18:40 Christian Biesinger (Code Review)
  2019-11-11 14:57 ` [review v2] " Tom Tromey (Code Review)
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-11-02 18:40 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/485
......................................................................

Use getpwuid_r instead of getpwuid when available

Change-Id: I587359267f8963ef1da6ba0223a1525807a721de
---
M gdb/config.in
M gdb/configure
M gdb/gdbserver/config.in
M gdb/gdbserver/configure
M gdb/gdbsupport/common.m4
M gdb/nat/linux-osdata.c
6 files changed, 17 insertions(+), 4 deletions(-)



diff --git a/gdb/config.in b/gdb/config.in
index 5a21fca..ef90fbb 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -186,6 +186,9 @@
 /* Define to 1 if you have the `getpgid' function. */
 #undef HAVE_GETPGID
 
+/* Define to 1 if you have the `getpwuid_r' function. */
+#undef HAVE_GETPWUID_R
+
 /* Define to 1 if you have the `getrlimit' function. */
 #undef HAVE_GETRLIMIT
 
diff --git a/gdb/configure b/gdb/configure
index 512f016..fbc6c65 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -13480,7 +13480,7 @@
 
 
   for ac_func in fdwalk getrlimit pipe pipe2 socketpair sigaction \
-		  sigprocmask strerror_r
+		  sigprocmask strerror_r getpwuid_r
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 2984281..e53afff 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -114,6 +114,9 @@
 /* Define to 1 if you have the `getauxval' function. */
 #undef HAVE_GETAUXVAL
 
+/* Define to 1 if you have the `getpwuid_r' function. */
+#undef HAVE_GETPWUID_R
+
 /* Define to 1 if you have the `getrlimit' function. */
 #undef HAVE_GETRLIMIT
 
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 3f1f1c1..3fe2ec6 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -6822,7 +6822,7 @@
 
 
   for ac_func in fdwalk getrlimit pipe pipe2 socketpair sigaction \
-		  sigprocmask strerror_r
+		  sigprocmask strerror_r getpwuid_r
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/gdb/gdbsupport/common.m4 b/gdb/gdbsupport/common.m4
index 2e44cf4..19e67e2 100644
--- a/gdb/gdbsupport/common.m4
+++ b/gdb/gdbsupport/common.m4
@@ -33,7 +33,7 @@
 		   dlfcn.h)
 
   AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair sigaction \
-		  sigprocmask strerror_r])
+		  sigprocmask strerror_r getpwuid_r])
 
   AC_CHECK_DECLS([strerror, strstr])
 
diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
index 67f9f3a..8b03a41 100644
--- a/gdb/nat/linux-osdata.c
+++ b/gdb/nat/linux-osdata.c
@@ -205,7 +205,14 @@
 static void
 user_from_uid (char *user, int maxlen, uid_t uid)
 {
-  struct passwd *pwentry = getpwuid (uid);
+  struct passwd *pwentry;
+#ifdef HAVE_GETPWUID_R
+  char buf[1024];
+  struct passwd pwd;
+  getpwuid_r (uid, &pwd, buf, sizeof (buf), &pwentry);
+#else
+  pwentry = getpwuid (uid);
+#endif
 
   if (pwentry)
     {

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I587359267f8963ef1da6ba0223a1525807a721de
Gerrit-Change-Number: 485
Gerrit-PatchSet: 1
Gerrit-Owner: Christian Biesinger <cbiesinger@google.com>
Gerrit-MessageType: newchange


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-11-11 23:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-02 18:40 [review] Use getpwuid_r instead of getpwuid when available Christian Biesinger (Code Review)
2019-11-11 14:57 ` [review v2] " Tom Tromey (Code Review)
2019-11-11 19:35 ` [review v3] Use getpwuid_r instead of getpwuid Christian Biesinger (Code Review)
2019-11-11 19:36 ` Christian Biesinger (Code Review)
2019-11-11 23:25 ` Tom Tromey (Code Review)
2019-11-11 23:29 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-11 23:29 ` Sourceware to Gerrit sync (Code Review)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox