multipath-tools/6022-multipathd-handle-NULL-return-from-genhelp_handler.patch

45 lines
1.2 KiB
Diff
Raw Normal View History

2020-01-10 17:13:17 +08:00
From dc8b964a03a547eb8dc62b317f9f168a35943ebf Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Fri, 17 May 2019 11:14:10 -0500
Subject: [PATCH 2/8] multipathd: handle NULL return from genhelp_handler
parse_cmd() wasn't checking if genhelp_handler() returned NULL. It was simply
assuming that it got a string. On NULL, it now returns an 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 a75afe3..ff17a5b 100644
--- a/multipathd/cli.c
+++ b/multipathd/cli.c
@@ -465,6 +465,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;
}
@@ -472,9 +474,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;
}
--
1.8.3.1