multipathd: fix buffer size in cli_getprkey()
authorMartin Wilck <mwilck@suse.com>
Sun, 24 Jun 2018 19:09:43 +0000 (21:09 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Mon, 2 Jul 2018 10:03:10 +0000 (12:03 +0200)
gcc 8.1 warned about this.

Signed-off-by: Martin Wilck <mwilck@suse.com>
multipathd/cli_handlers.c

index 47830e1..5682b5c 100644 (file)
@@ -1449,7 +1449,7 @@ cli_getprkey(void * v, char ** reply, int * len, void * data)
        if (!mpp)
                return 1;
 
-       *reply = malloc(20);
+       *reply = malloc(26);
 
        if (!get_be64(mpp->reservation_key)) {
                sprintf(*reply, "none\n");
@@ -1458,7 +1458,7 @@ cli_getprkey(void * v, char ** reply, int * len, void * data)
        }
        if (mpp->sa_flags & MPATH_F_APTPL_MASK)
                flagstr = ":aptpl";
-       snprintf(*reply, 20, "0x%" PRIx64 "%s\n",
+       snprintf(*reply, 26, "0x%" PRIx64 "%s\n",
                 get_be64(mpp->reservation_key), flagstr);
        (*reply)[19] = '\0';
        *len = strlen(*reply) + 1;