1From 4328f1db48ef4a0ec90a63c344c97063ade3e94a Mon Sep 17 00:00:00 2001 2From: Martin Sebor <msebor@redhat.com> 3Date: Thu, 8 Oct 2020 12:53:09 -0600 4Subject: [PATCH 10/20] sunrpc: Adjust RPC function declarations to match Sun's 5 (bug 26686] 6 7Building Glibc with the latest GCC 11 shows a number of instances 8of the new -Warray-parameter warning designed to encourage 9consistency in the forms of array arguments in redeclarations of 10the same function (and, ultimately, to enable the detection of out 11of bounds accesses via such arguments). 12 13To avoid the subset of these warnings for the RPC APIs, this patch 14changes the declarations of these functions to match both their 15definitions and the Oracle RPC documentation. 16 17Besides avoiding the -Warray-parameter warnings the effect of this 18change is for GCC to issue warnings when either the functions are 19passed an array with fewer than MAXNETNAMELEN + 1 elements, or when 20the functions themselves access elements outside the array bounds. 21 22(cherry picked from commit c5db00dc30e0513dc17ad8aefe54c807f55ec967) 23Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 24--- 25 sunrpc/netname.c | 5 ++--- 26 sunrpc/rpc/auth.h | 8 +++++--- 27 2 files changed, 7 insertions(+), 6 deletions(-) 28 29diff --git a/sunrpc/netname.c b/sunrpc/netname.c 30index 4e3730ce..2695870f 100644 31--- a/sunrpc/netname.c 32+++ b/sunrpc/netname.c 33@@ -142,7 +142,7 @@ typedef int (*netname2user_function) (const char netname[MAXNETNAMELEN + 1], 34 uid_t *, gid_t *, int *, gid_t *); 35 36 int 37-netname2user (const char netname[MAXNETNAMELEN + 1], uid_t * uidp, gid_t * gidp, 38+netname2user (const char *netname, uid_t * uidp, gid_t * gidp, 39 int *gidlenp, gid_t * gidlist) 40 { 41 static service_user *startp; 42@@ -189,8 +189,7 @@ libc_hidden_nolink_sunrpc (netname2user, GLIBC_2_1) 43 #endif 44 45 int 46-netname2host (const char netname[MAXNETNAMELEN + 1], char *hostname, 47- const int hostlen) 48+netname2host (const char *netname, char *hostname, const int hostlen) 49 { 50 char *p1, *p2; 51 52diff --git a/sunrpc/rpc/auth.h b/sunrpc/rpc/auth.h 53index e01b0772..0b464088 100644 54--- a/sunrpc/rpc/auth.h 55+++ b/sunrpc/rpc/auth.h 56@@ -179,9 +179,11 @@ extern AUTH *authdes_pk_create (const char *, netobj *, u_int, 57 * Netname manipulating functions 58 * 59 */ 60-extern int getnetname (char *) __THROW; 61-extern int host2netname (char *, const char *, const char *) __THROW; 62-extern int user2netname (char *, const uid_t, const char *) __THROW; 63+extern int getnetname (char [MAXNETNAMELEN + 1]) __THROW; 64+extern int host2netname (char [MAXNETNAMELEN + 1], const char *, 65+ const char *) __THROW; 66+extern int user2netname (char [MAXNETNAMELEN + 1], const uid_t, 67+ const char *) __THROW; 68 extern int netname2user (const char *, uid_t *, gid_t *, int *, gid_t *) 69 __THROW; 70 extern int netname2host (const char *, char *, const int) __THROW; 71-- 722.20.1 73 74