]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
sunrpc: Adjust RPC function declarations to match Sun's (bug 26686]
authorMartin Sebor <msebor@redhat.com>
Thu, 8 Oct 2020 18:53:09 +0000 (12:53 -0600)
committerMartin Sebor <msebor@redhat.com>
Thu, 8 Oct 2020 18:53:09 +0000 (12:53 -0600)
Building Glibc with the latest GCC 11 shows a number of instances
of the new -Warray-parameter warning designed to encourage
consistency in the forms of array arguments in redeclarations of
the same function (and, ultimately, to enable the detection of out
of bounds accesses via such arguments).

To avoid the subset of these warnings for the RPC APIs, this patch
changes the declarations of these functions to match both their
definitions and the Oracle RPC documentation.

Besides avoiding the -Warray-parameter warnings the effect of this
change is for GCC to issue warnings when either the functions are
passed an array with fewer than MAXNETNAMELEN + 1 elements, or when
the functions themselves access elements outside the array bounds.

sunrpc/netname.c
sunrpc/rpc/auth.h

index 61d82ca31a825c1ef68d7bc413be23fda94032a2..24ee519e42a3b51586f9f4c8158e9323a88a6c64 100644 (file)
@@ -142,7 +142,7 @@ typedef int (*netname2user_function) (const char netname[MAXNETNAMELEN + 1],
                                      uid_t *, gid_t *, int *, gid_t *);
 
 int
-netname2user (const char netname[MAXNETNAMELEN + 1], uid_t * uidp, gid_t * gidp,
+netname2user (const char *netname, uid_t * uidp, gid_t * gidp,
              int *gidlenp, gid_t * gidlist)
 {
   static service_user *startp;
@@ -189,8 +189,7 @@ libc_hidden_nolink_sunrpc (netname2user, GLIBC_2_1)
 #endif
 
 int
-netname2host (const char netname[MAXNETNAMELEN + 1], char *hostname,
-             const int hostlen)
+netname2host (const char *netname, char *hostname, const int hostlen)
 {
   char *p1, *p2;
 
index e01b0772147017a65bf012bfb824acb1a33cb67a..0b46408890d1f074dc5b61359ba4dd87881d9f07 100644 (file)
@@ -179,9 +179,11 @@ extern AUTH *authdes_pk_create (const char *, netobj *, u_int,
  *  Netname manipulating functions
  *
  */
-extern int getnetname (char *) __THROW;
-extern int host2netname (char *, const char *, const char *) __THROW;
-extern int user2netname (char *, const uid_t, const char *) __THROW;
+extern int getnetname (char [MAXNETNAMELEN + 1]) __THROW;
+extern int host2netname (char [MAXNETNAMELEN + 1], const char *,
+                        const char *) __THROW;
+extern int user2netname (char [MAXNETNAMELEN + 1], const uid_t,
+                        const char *) __THROW;
 extern int netname2user (const char *, uid_t *, gid_t *, int *, gid_t *)
      __THROW;
 extern int netname2host (const char *, char *, const int) __THROW;