diff mbox series

[1/2] libmultipath: check for null wwid before strcmp

Message ID 1609819195-18306-2-git-send-email-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath cleanup patches | expand

Commit Message

Benjamin Marzinski Jan. 5, 2021, 3:59 a.m. UTC
Commit 749aabd0 (libmultipath: ignore multipaths sections without wwid
option) removed all mpentries with a NULL wwid, but didn't stop strcmp()
from being run on them in merge_mptable(). The result of strcmp() with
a NULL parameter is undefined, so fix that.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libmultipath/config.c b/libmultipath/config.c
index a643703e..be310159 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -518,7 +518,7 @@  void merge_mptable(vector mptable)
 		}
 		j = i + 1;
 		vector_foreach_slot_after(mptable, mp2, j) {
-			if (strcmp(mp1->wwid, mp2->wwid))
+			if (!mp2->wwid || strcmp(mp1->wwid, mp2->wwid))
 				continue;
 			condlog(1, "%s: duplicate multipath config section for %s",
 				__func__, mp1->wwid);