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 <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
Artur Wojcik 2009-12-10 12:03:40 -07:00 committed by Dan Williams
parent d362da3dfe
commit 4e5e717d72
1 changed files with 6 additions and 0 deletions

View 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;