]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix for NULL pointer dereference defect.
authorArtur Wojcik <artur.wojcik@intel.com>
Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)
committerDan Williams <dan.j.williams@intel.com>
Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)
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 <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
super-intel.c

index da753a0a482a6ad3997c06fda868af818105b046..72fa68fb61fe84a8ad8aace8777e0eedb62cad50 100644 (file)
@@ -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;