From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104412 invoked by alias); 2 Nov 2019 18:40:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 104404 invoked by uid 89); 2 Nov 2019 18:40:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 02 Nov 2019 18:40:22 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 5CCC020339; Sat, 2 Nov 2019 14:40:20 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 3326A20322; Sat, 2 Nov 2019 14:40:19 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 03F1220AF6; Sat, 2 Nov 2019 14:40:19 -0400 (EDT) X-Gerrit-PatchSet: 1 Date: Sat, 02 Nov 2019 18:40:00 -0000 From: "Christian Biesinger (Code Review)" To: gdb-patches@sourceware.org Cc: Christian Biesinger Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Use getpwuid_r instead of getpwuid when available X-Gerrit-Change-Id: I587359267f8963ef1da6ba0223a1525807a721de X-Gerrit-Change-Number: 485 X-Gerrit-ChangeURL: X-Gerrit-Commit: c19bedcfb40ea7c4bf6409efa975522b11b1a4d4 References: Reply-To: cbiesinger@google.com, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-75-g9005159e5d Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2019-11/txt/msg00052.txt.bz2 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 Gerrit-MessageType: newchange