Skip to contentSkip to conversation

bfa: Add support to read/update the FRU data.

SCSI Dan Carpenter 1 participant 1 message Oct 11, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello Krishna Gudipati,

The patch e6826c96ced7: "[SCSI] bfa: Add support to read/update the FRU data." from Sep 21, 2012, leads to the following warning:
drivers/scsi/bfa/bfad_bsg.c:114 bfad_iocmd_ioc_get_info()

	 error: buffer overflow 'iocmd->adapter_hwpath' 32 <= 32
drivers/scsi/bfa/bfad_bsg.c +2 -3
index 0ab1d40..555e7db 100644
@@ -107,9 +107,10 @@ bfad_iocmd_ioc_get_info(struct bfad_s *bfad, void *cmd)
 
        /* set adapter hw path */
        strcpy(iocmd->adapter_hwpath, bfad->pci_name);
-       i = strlen(iocmd->adapter_hwpath) - 1;
-       while (iocmd->adapter_hwpath[i] != '.')
-               i--;
+       for (i = 0; iocmd->adapter_hwpath[i] != ':' && i < BFA_STRING_32; i++)
+               ;
 

i is 32 here.

+ for (; iocmd->adapter_hwpath[++i] != ':' && i < BFA_STRING_32; )
+ ;

i is 33 after the increment.

        iocmd->adapter_hwpath[i] = '\0';

We are placing a NUL char 2 places past the end of the array.

        iocmd->status = BFA_STATUS_OK;
        return 0;

regards,
dan carpenter