* [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
* [review v2] Use getpwuid_r instead of getpwuid when available
2019-11-02 18:40 [review] Use getpwuid_r instead of getpwuid when available Christian Biesinger (Code Review)
@ 2019-11-11 14:57 ` Tom Tromey (Code Review)
2019-11-11 19:35 ` [review v3] Use getpwuid_r instead of getpwuid Christian Biesinger (Code Review)
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-11 14:57 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches
Tom Tromey has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/485
......................................................................
Patch Set 2:
(1 comment)
Thank you for this and the other "_r" patches.
I think this one can be hugely simplified, see below.
| --- gdb/nat/linux-osdata.c
| +++ gdb/nat/linux-osdata.c
| @@ -204,11 +204,18 @@ /* Finds the user name for the user UID and copies it into USER. At
|
| 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);
PS2, Line 212:
I think that, because the only use is in a "nat" file,
and because we know this is always available on Linux,
then there's no need for the configury. We can just call
this unconditionally.
| +#else
| + pwentry = getpwuid (uid);
| +#endif
|
| if (pwentry)
| {
| strncpy (user, pwentry->pw_name, maxlen);
| /* Ensure that the user name is null-terminated. */
| user[maxlen - 1] = '\0';
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I587359267f8963ef1da6ba0223a1525807a721de
Gerrit-Change-Number: 485
Gerrit-PatchSet: 2
Gerrit-Owner: Christian Biesinger <cbiesinger@google.com>
Gerrit-CC: Tom Tromey <tromey@sourceware.org>
Gerrit-Comment-Date: Mon, 11 Nov 2019 14:57:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 7+ messages in thread
* [review v3] Use getpwuid_r instead of getpwuid
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 ` Christian Biesinger (Code Review)
2019-11-11 19:36 ` Christian Biesinger (Code Review)
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-11-11 19:35 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches; +Cc: Tom Tromey
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(-)
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)
{
--
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [review v3] Use getpwuid_r instead of getpwuid
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)
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-11-11 19:36 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches; +Cc: Tom Tromey
Christian Biesinger has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/485
......................................................................
Patch Set 3:
(1 comment)
| --- gdb/nat/linux-osdata.c
| +++ gdb/nat/linux-osdata.c
| @@ -204,11 +204,18 @@ /* Finds the user name for the user UID and copies it into USER. At
|
| 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);
PS2, Line 212:
Oh good point! Done.
| +#else
| + pwentry = getpwuid (uid);
| +#endif
|
| if (pwentry)
| {
| strncpy (user, pwentry->pw_name, maxlen);
| /* Ensure that the user name is null-terminated. */
| user[maxlen - 1] = '\0';
--
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-Reviewer: Christian Biesinger <cbiesinger@google.com>
Gerrit-CC: Tom Tromey <tromey@sourceware.org>
Gerrit-Comment-Date: Mon, 11 Nov 2019 19:36:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 7+ messages in thread
* [review v3] Use getpwuid_r instead of getpwuid
2019-11-02 18:40 [review] Use getpwuid_r instead of getpwuid when available Christian Biesinger (Code Review)
` (2 preceding siblings ...)
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)
5 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-11 23:25 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches
Tom Tromey has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/485
......................................................................
Patch Set 3: Code-Review+2
Looks good! Thanks.
--
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-Reviewer: Christian Biesinger <cbiesinger@google.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-Comment-Date: Mon, 11 Nov 2019 23:25:12 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pushed] Use getpwuid_r instead of getpwuid
2019-11-02 18:40 [review] Use getpwuid_r instead of getpwuid when available Christian Biesinger (Code Review)
` (4 preceding siblings ...)
2019-11-11 23:29 ` [pushed] " Sourceware to Gerrit sync (Code Review)
@ 2019-11-11 23:29 ` Sourceware to Gerrit sync (Code Review)
5 siblings, 0 replies; 7+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-11 23:29 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches; +Cc: Tom Tromey
Sourceware to Gerrit sync has submitted this change.
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/ChangeLog
M gdb/nat/linux-osdata.c
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dd280ec..edd3e90 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2019-11-11 Christian Biesinger <cbiesinger@google.com>
+
+ * nat/linux-osdata.c (user_from_uid): Use getpwuid_r.
+
2019-11-10 Andrew Burgess <andrew.burgess@embecosm.com>
* python/py-symbol.c (gdbpy_lookup_static_symbols): New
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)
{
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I587359267f8963ef1da6ba0223a1525807a721de
Gerrit-Change-Number: 485
Gerrit-PatchSet: 4
Gerrit-Owner: Christian Biesinger <cbiesinger@google.com>
Gerrit-Reviewer: Christian Biesinger <cbiesinger@google.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: merged
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pushed] Use getpwuid_r instead of getpwuid
2019-11-02 18:40 [review] Use getpwuid_r instead of getpwuid when available Christian Biesinger (Code Review)
` (3 preceding siblings ...)
2019-11-11 23:25 ` Tom Tromey (Code Review)
@ 2019-11-11 23:29 ` Sourceware to Gerrit sync (Code Review)
2019-11-11 23:29 ` Sourceware to Gerrit sync (Code Review)
5 siblings, 0 replies; 7+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-11 23:29 UTC (permalink / raw)
To: Christian Biesinger, Tom Tromey, gdb-patches
The original change was created by Christian Biesinger.
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/ChangeLog
M gdb/nat/linux-osdata.c
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dd280ec..edd3e90 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2019-11-11 Christian Biesinger <cbiesinger@google.com>
+
+ * nat/linux-osdata.c (user_from_uid): Use getpwuid_r.
+
2019-11-10 Andrew Burgess <andrew.burgess@embecosm.com>
* python/py-symbol.c (gdbpy_lookup_static_symbols): New
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)
{
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I587359267f8963ef1da6ba0223a1525807a721de
Gerrit-Change-Number: 485
Gerrit-PatchSet: 4
Gerrit-Owner: Christian Biesinger <cbiesinger@google.com>
Gerrit-Reviewer: Christian Biesinger <cbiesinger@google.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newpatchset
^ 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