SUNRPC: Fix -Wformat-truncation warning
authorKunwu Chan <chentao@kylinos.cn>
Fri, 16 Aug 2024 02:07:40 +0000 (10:07 +0800)
committerAnna Schumaker <anna.schumaker@oracle.com>
Mon, 23 Sep 2024 19:03:13 +0000 (15:03 -0400)
Increase size of the servername array to avoid truncated output warning.

net/sunrpc/clnt.c:582:75: error:‘%s’ directive output may be truncated
writing up to 107 bytes into a region of size 48
[-Werror=format-truncation=]
  582 |                   snprintf(servername, sizeof(servername), "%s",
      |                                                             ^~

net/sunrpc/clnt.c:582:33: note:‘snprintf’ output
between 1 and 108 bytes into a destination of size 48
  582 |                     snprintf(servername, sizeof(servername), "%s",
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  583 |                                          sun->sun_path);

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Suggested-by: NeilBrown <neilb@suse.de>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
net/sunrpc/clnt.c

index 09f29a95f2bc3553779066e1c97193843e206a05..c7cea069a5df00f515ff4992d36db955a7edb1e0 100644 (file)
@@ -546,7 +546,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
                .connect_timeout = args->connect_timeout,
                .reconnect_timeout = args->reconnect_timeout,
        };
-       char servername[48];
+       char servername[RPC_MAXNETNAMELEN];
        struct rpc_clnt *clnt;
        int i;