Blame SOURCES/0034-multipathd-handle-NULL-return-from-genhelp_handler.patch

a1c519
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
a1c519
From: Benjamin Marzinski <bmarzins@redhat.com>
a1c519
Date: Thu, 16 May 2019 15:44:20 -0500
a1c519
Subject: [PATCH] multipathd: handle NULL return from genhelp_handler
a1c519
a1c519
If parse_cmd() wasn't checking if genhelp_handler() returned NULL. It
a1c519
was simply assuming that it got a string. Instead, it should just return
a1c519
and error. Found by Coverity.
a1c519
a1c519
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
a1c519
---
a1c519
 multipathd/cli.c | 6 +++++-
a1c519
 1 file changed, 5 insertions(+), 1 deletion(-)
a1c519
a1c519
diff --git a/multipathd/cli.c b/multipathd/cli.c
a1c519
index ca176a9..17795b6 100644
a1c519
--- a/multipathd/cli.c
a1c519
+++ b/multipathd/cli.c
a1c519
@@ -467,6 +467,8 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data, int timeout )
a1c519
 
a1c519
 	if (r) {
a1c519
 		*reply = genhelp_handler(cmd, r);
a1c519
+		if (*reply == NULL)
a1c519
+			return EINVAL;
a1c519
 		*len = strlen(*reply) + 1;
a1c519
 		return 0;
a1c519
 	}
a1c519
@@ -474,9 +476,11 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data, int timeout )
a1c519
 	h = find_handler(fingerprint(cmdvec));
a1c519
 
a1c519
 	if (!h || !h->fn) {
a1c519
+		free_keys(cmdvec);
a1c519
 		*reply = genhelp_handler(cmd, EINVAL);
a1c519
+		if (*reply == NULL)
a1c519
+			return EINVAL;
a1c519
 		*len = strlen(*reply) + 1;
a1c519
-		free_keys(cmdvec);
a1c519
 		return 0;
a1c519
 	}
a1c519
 
a1c519
-- 
a1c519
2.17.2
a1c519