libmultipath: fix set_int error path
authorBenjamin Marzinski <bmarzins@redhat.com>
Tue, 9 Oct 2018 23:03:03 +0000 (18:03 -0500)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 10 Oct 2018 06:09:30 +0000 (08:09 +0200)
set_int() wasn't checking if the line actually had a value before
converting it to an integer.  Found by coverity. Also, it should
be using set_value().

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
libmultipath/dict.c

index 32524d5..bf4701e 100644 (file)
@@ -33,7 +33,10 @@ set_int(vector strvec, void *ptr)
        int *int_ptr = (int *)ptr;
        char * buff;
 
-       buff = VECTOR_SLOT(strvec, 1);
+       buff = set_value(strvec);
+       if (!buff)
+               return 1;
+
        *int_ptr = atoi(buff);
 
        return 0;