device-mapper-multipath/SOURCES/0034-multipathd-handle-NULL-return-from-genhelp_handler.patch
2021-10-08 10:24:22 +00:00

44 lines
1.2 KiB
Diff

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