device-mapper-multipath-0.8.6-6

Add 0022-multipathd-cli_handlers-cleanup-setting-reply-length.patch
  * Found by corosync
Related: bz #1984921
This commit is contained in:
Benjamin Marzinski 2021-08-03 15:29:16 -05:00
parent e6aef775e4
commit 27594c740e
2 changed files with 89 additions and 1 deletions

View File

@ -0,0 +1,82 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Mon, 17 May 2021 22:37:34 +0200
Subject: [PATCH] multipathd: cli_handlers: cleanup setting reply length
Create a macro for setting the reply length for string literals
correctly, and use it where necessary.
In cli_del_path(), don't change the function's return code
if just the buffer allocation for the reply failed.
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipathd/cli_handlers.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 6765fcf0..96064944 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -32,6 +32,12 @@
#include "foreign.h"
#include "cli_handlers.h"
+#define SET_REPLY_AND_LEN(__rep, __len, string_literal) \
+ do { \
+ *(__rep) = strdup(string_literal); \
+ *(__len) = *(__rep) ? sizeof(string_literal) : 0; \
+ } while (0)
+
int
show_paths (char ** r, int * len, struct vectors * vecs, char * style,
int pretty)
@@ -802,8 +808,7 @@ cli_add_path (void * v, char ** reply, int * len, void * data)
}
return ev_add_path(pp, vecs, 1);
blacklisted:
- *reply = strdup("blacklisted\n");
- *len = strlen(*reply) + 1;
+ SET_REPLY_AND_LEN(reply, len, "blacklisted\n");
condlog(2, "%s: path blacklisted", param);
return 0;
}
@@ -824,23 +829,10 @@ cli_del_path (void * v, char ** reply, int * len, void * data)
return 1;
}
ret = ev_remove_path(pp, vecs, 1);
- if (ret == REMOVE_PATH_DELAY) {
- *reply = strdup("delayed\n");
- if (*reply)
- *len = strlen(*reply) + 1;
- else {
- *len = 0;
- ret = REMOVE_PATH_FAILURE;
- }
- } else if (ret == REMOVE_PATH_MAP_ERROR) {
- *reply = strdup("map reload error. removed\n");
- if (*reply)
- *len = strlen(*reply) + 1;
- else {
- *len = 0;
- ret = REMOVE_PATH_FAILURE;
- }
- }
+ if (ret == REMOVE_PATH_DELAY)
+ SET_REPLY_AND_LEN(reply, len, "delayed\n");
+ else if (ret == REMOVE_PATH_MAP_ERROR)
+ SET_REPLY_AND_LEN(reply, len, "map reload error. removed\n");
return (ret == REMOVE_PATH_FAILURE);
}
@@ -865,8 +857,7 @@ cli_add_map (void * v, char ** reply, int * len, void * data)
invalid = 1;
pthread_cleanup_pop(1);
if (invalid) {
- *reply = strdup("blacklisted\n");
- *len = strlen(*reply) + 1;
+ SET_REPLY_AND_LEN(reply, len, "blacklisted\n");
condlog(2, "%s: map blacklisted", param);
return 1;
}

View File

@ -1,6 +1,6 @@
Name: device-mapper-multipath Name: device-mapper-multipath
Version: 0.8.6 Version: 0.8.6
Release: 5%{?dist} Release: 6%{?dist}
Summary: Tools to manage multipath devices using device-mapper Summary: Tools to manage multipath devices using device-mapper
License: GPLv2 License: GPLv2
URL: http://christophe.varoqui.free.fr/ URL: http://christophe.varoqui.free.fr/
@ -31,6 +31,7 @@ Patch0018: 0018-multipath.conf-fix-typo-in-ghost_delay-description.patch
Patch0019: 0019-mpathpersist-fail-commands-when-no-usable-paths-exis.patch Patch0019: 0019-mpathpersist-fail-commands-when-no-usable-paths-exis.patch
Patch0020: 0020-multipath-print-warning-if-multipathd-is-not-running.patch Patch0020: 0020-multipath-print-warning-if-multipathd-is-not-running.patch
Patch0021: 0021-libmultipath-deal-with-dynamic-PTHREAD_STACK_MIN.patch Patch0021: 0021-libmultipath-deal-with-dynamic-PTHREAD_STACK_MIN.patch
Patch0022: 0022-multipathd-cli_handlers-cleanup-setting-reply-length.patch
# runtime # runtime
Requires: %{name}-libs = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release}
@ -229,6 +230,11 @@ fi
%{_pkgconfdir}/libdmmp.pc %{_pkgconfdir}/libdmmp.pc
%changelog %changelog
* Fri Jul 23 2021 Benjamin Marzinski <bmarzins@redhat.com> - 0.8.6-6
- Add 0022-multipathd-cli_handlers-cleanup-setting-reply-length.patch
* Found by corosync
- Related: bz #1984921
* Fri Jul 23 2021 Benjamin Marzinski <bmarzins@redhat.com> - 0.8.6-5 * Fri Jul 23 2021 Benjamin Marzinski <bmarzins@redhat.com> - 0.8.6-5
- Add 0018-multipath.conf-fix-typo-in-ghost_delay-description.patch - Add 0018-multipath.conf-fix-typo-in-ghost_delay-description.patch
- Add 0019-mpathpersist-fail-commands-when-no-usable-paths-exis.patch - Add 0019-mpathpersist-fail-commands-when-no-usable-paths-exis.patch