From: "Christian Biesinger (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: gdb-patches@sourceware.org
Cc: Christian Biesinger <cbiesinger@google.com>
Subject: [review] Use getpwuid_r instead of getpwuid when available
Date: Sat, 02 Nov 2019 18:40:00 -0000 [thread overview]
Message-ID: <gerrit.1572720018000.I587359267f8963ef1da6ba0223a1525807a721de@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1572720018000.I587359267f8963ef1da6ba0223a1525807a721de@gnutoolchain-gerrit.osci.io>
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
next parent reply other threads:[~2019-11-02 18:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-02 18:40 Christian Biesinger (Code Review) [this message]
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)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=gerrit.1572720018000.I587359267f8963ef1da6ba0223a1525807a721de@gnutoolchain-gerrit.osci.io \
--to=gerrit@gnutoolchain-gerrit.osci.io \
--cc=cbiesinger@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox