device-mapper-multipath/0013-multipathd-fix-show-maps-json-crash.patch
Benjamin Marzinski c9012ec5b7 device-mapper-multipath-0.7.1-2.gitf21166a
Modify 0004-RH-Remove-the-property-blacklist-exception-builtin.patch
  * update multipath.conf.5 man page to remove builtin listing
Modify 0005-RH-don-t-start-without-a-config-file.patch
  * update multipathd.8 man page to note that a config file is necessary
Modify 0007-RH-add-mpathconf.patch
  * add property blacklist-exception to default config file
Add 0010-libmultipath-change-how-RADOS-checker-is-enabled.patch
  * Makefile now autodetects librados. Posted upstream
Remove related RADOS option from spec file
Add 0011-multipath-set-verbosity-to-default-during-config.patch
  * Allow multipath to print warning messages during configuration.
    Posted upstream
Add 0012-mpath-skip-device-configs-without-vendor-product.patch
  * device entries without vendor/product were breaking configurations.
    Posted upsteam
Add 0013-multipathd-fix-show-maps-json-crash.patch
  * multipathd crashed showing json output with no devices. Posted
    upstream
2017-06-02 00:34:02 -05:00

39 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Thu, 1 Jun 2017 17:52:28 -0500
Subject: [PATCH] multipathd: fix "show maps json" crash
If there are no multipath devices, show_maps_json sets the maximum size
of the reply buffer to 0. Having a size of 0 causes the calls to calloc
and realloc to behave in ways that the code isn't designed to handle,
leading to a double-free crash. Instead, show_maps_json should just
use the INITIAL_REPLY_LEN if there are no multipath devices.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipathd/cli_handlers.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 04c7386..7b0d00c 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -162,10 +162,12 @@ show_maps_json (char ** r, int * len, struct vectors * vecs)
struct multipath * mpp;
char * c;
char * reply;
- unsigned int maxlen = INITIAL_REPLY_LEN *
- PRINT_JSON_MULTIPLIER * VECTOR_SIZE(vecs->mpvec);
+ unsigned int maxlen = INITIAL_REPLY_LEN;
int again = 1;
+ if (VECTOR_SIZE(vecs->mpvec) > 0)
+ maxlen *= PRINT_JSON_MULTIPLIER * VECTOR_SIZE(vecs->mpvec);
+
vector_foreach_slot(vecs->mpvec, mpp, i) {
if (update_multipath(vecs, mpp->alias, 0)) {
return 1;
--
2.7.4