c64a48b95f
Pull in latest upstream post-tag commits * Patches 0001-0015 are from https://github.com/openSUSE/multipath-tools/tree/queue and are already queued for upstream Rename files * Previous patches 0001-0010 and now patches 0016-0025
54 lines
1.8 KiB
Diff
54 lines
1.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martin Wilck <mwilck@suse.com>
|
|
Date: Mon, 17 May 2021 22:45:05 +0200
|
|
Subject: [PATCH] multipathd: cli_getprkey(): fix return value
|
|
|
|
By setting (*reply)[19] = '\0', we always truncated a possible
|
|
":aptpl" suffix. Fix it, and use the return value of snprintf()
|
|
as length.
|
|
|
|
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
---
|
|
multipathd/cli_handlers.c | 17 ++++++++---------
|
|
1 file changed, 8 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
|
|
index 96064944..59d44b45 100644
|
|
--- a/multipathd/cli_handlers.c
|
|
+++ b/multipathd/cli_handlers.c
|
|
@@ -1540,7 +1540,7 @@ cli_getprkey(void * v, char ** reply, int * len, void * data)
|
|
struct multipath * mpp;
|
|
struct vectors * vecs = (struct vectors *)data;
|
|
char *mapname = get_keyparam(v, MAP);
|
|
- char *flagstr = "";
|
|
+ uint64_t key;
|
|
|
|
mapname = convert_dev(mapname, 0);
|
|
condlog(3, "%s: get persistent reservation key (operator)", mapname);
|
|
@@ -1553,17 +1553,16 @@ cli_getprkey(void * v, char ** reply, int * len, void * data)
|
|
if (!*reply)
|
|
return 1;
|
|
|
|
- if (!get_be64(mpp->reservation_key)) {
|
|
+ key = get_be64(mpp->reservation_key);
|
|
+ if (!key) {
|
|
sprintf(*reply, "none\n");
|
|
- *len = strlen(*reply) + 1;
|
|
+ *len = sizeof("none\n");
|
|
return 0;
|
|
}
|
|
- if (mpp->sa_flags & MPATH_F_APTPL_MASK)
|
|
- flagstr = ":aptpl";
|
|
- snprintf(*reply, 26, "0x%" PRIx64 "%s\n",
|
|
- get_be64(mpp->reservation_key), flagstr);
|
|
- (*reply)[19] = '\0';
|
|
- *len = strlen(*reply) + 1;
|
|
+
|
|
+ /* This snprintf() can't overflow - PRIx64 needs max 16 chars */
|
|
+ *len = snprintf(*reply, 26, "0x%" PRIx64 "%s\n", key,
|
|
+ mpp->sa_flags & MPATH_F_APTPL_MASK ? ":aptpl" : "") + 1;
|
|
return 0;
|
|
}
|
|
|