From: Artur Wojcik Date: Thu, 10 Dec 2009 19:03:40 +0000 (-0700) Subject: Fix for NULL pointer dereference defect. X-Git-Tag: mdadm-3.1.2~63^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e5e717d72453bed761f561f24393d95d1817352;p=thirdparty%2Fmdadm.git Fix for NULL pointer dereference defect. Pointer 'c' returned from call to function 'strchr' at line 954 may be NULL and will be dereferenced at line 955. Signed-off-by: Artur Wojcik Signed-off-by: Dan Williams --- diff --git a/super-intel.c b/super-intel.c index da753a0a..72fa68fb 100644 --- a/super-intel.c +++ b/super-intel.c @@ -961,6 +961,12 @@ static int imsm_enumerate_ports(const char *hba_path, int port_count, int host_b /* chop device path to 'host%d' and calculate the port number */ c = strchr(&path[hba_len], '/'); + if (!c) { + if (verbose) + fprintf(stderr, Name ": %s - invalid path name\n", path + hba_len); + err = 2; + break; + } *c = '\0'; if (sscanf(&path[hba_len], "host%d", &port) == 1) port -= host_base;