libmultipath: fix segfault when vector is null
PATCH 1/1 libmultipath: fix segfault when vector is null
From: Mike Christie <[email protected]>
While performing tests that caused paths to get added and deleted, we hit a segfault. We traced it to the vector struct being NULL. This patch fixes the problem by checking for a NULL vector before accessing it.
Signed-off-by Mike Christie <[email protected]>
--- libmultipath/vector.c | 3 +++ 1 file changed, 3 insertions(+)
libmultipath/vector.c +3 -0
@@ -94,6 +94,9 @@ find_slot(vector v, void * addr) {int i; +if (!v) +return -1 ; +for (i =0 ; i < (v->allocated /VECTOR_DEFAULT_SIZE ); i++)if (v->slot[i] == addr)return i;
Signature · 1 line
1.7.11.2
Christophe Varoqui
AppliedQuoted 7 lines · On mar., 2013-01-08 at 13:36 -0600, [email protected] wrote:
From: Mike Christie <[email protected]>
While performing tests that caused paths to get added and deleted, we hit a segfault. We traced it to the vector struct being NULL. This patch fixes the problem by checking for a NULL vector before accessing it.
Applied.
Thanks,
Christophe Varoqui
www.opensvc.com
Quoted 19 lines
Signed-off-by Mike Christie <[email protected]>--- libmultipath/vector.c | 3 +++ 1 file changed, 3 insertions(+)libmultipath/vector.c +3
-0@@ -94,6 +94,9 @@ find_slot(vector v, void * addr) {int i; +if (!v) +return -1 ; +for (i =0 ; i < (v->allocated /VECTOR_DEFAULT_SIZE ); i++)if (v->slot[i] == addr)return i;