multipath segfaults if configuration file contains errors
authorHannes Reinecke <hare@suse.de>
Thu, 5 Nov 2009 13:52:05 +0000 (14:52 +0100)
committerHannes Reinecke <hare@suse.de>
Tue, 3 May 2011 08:38:51 +0000 (10:38 +0200)
This patch prevents multipath from crashing on invalid
configuration file when mandatory configuration values
are missing.

References: bnc#540118

Signed-off-by: Leonardo Chiquitto <lchiquitto@novell.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/parser.c

index b964ce7..a2cbd70 100644 (file)
@@ -387,12 +387,19 @@ void *
 set_value(vector strvec)
 {
        char *str = VECTOR_SLOT(strvec, 1);
-       int size = strlen(str);
+       size_t size;
        int i = 0;
        int len = 0;
        char *alloc = NULL;
        char *tmp;
 
+       if (!str)
+               return NULL;
+
+       size = strlen(str);
+       if (size == 0)
+               return NULL;
+
        if (*str == '"') {
                for (i = 2; i < VECTOR_SIZE(strvec); i++) {
                        str = VECTOR_SLOT(strvec, i);