From nobody Mon Sep 17 00:00:00 2001
From: Christophe Varoqui <root@xa-s05.(none)>
Date: Fri Jun 2 21:56:16 2006 +0200
Subject: [PATCH] [libmultipath] fix segv in load_config()

segv when a vendor or product string was not set in the
configuration file.

Note that now

device {
	vendor DCG
}

means :

device {
	vendor DCG
	product *
}
(cherry picked from c30f2a5bb7919d1482ff5d1de5e34b34786e3eec commit)

---

 libmultipath/config.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

4d24a3b424db83b21d30e20cc01530802a2aa400
diff --git a/libmultipath/config.c b/libmultipath/config.c
index c9d6172..a87e97e 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -28,14 +28,16 @@ find_hwe (vector hwtable, char * vendor,
 	regex_t vre, pre;
 
 	vector_foreach_slot (hwtable, hwe, i) {
-		if (regcomp(&vre, hwe->vendor, REG_EXTENDED|REG_NOSUB))
+		if (hwe->vendor &&
+		    regcomp(&vre, hwe->vendor, REG_EXTENDED|REG_NOSUB))
 			break;
-		if (regcomp(&pre, hwe->product, REG_EXTENDED|REG_NOSUB)) {
+		if (hwe->product &&
+		    regcomp(&pre, hwe->product, REG_EXTENDED|REG_NOSUB)) {
 			regfree(&vre);
 			break;
 		}
-		if (!regexec(&vre, vendor, 0, NULL, 0) &&
-		    !regexec(&pre, product, 0, NULL, 0))
+		if ((!hwe->vendor || !regexec(&vre, vendor, 0, NULL, 0)) &&
+		    (!hwe->product || !regexec(&pre, product, 0, NULL, 0)))
 			ret = hwe;
 		
 		regfree(&pre);
-- 
1.3.1

