aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFerenc Wagner <wferi@niif.hu>2011-08-25 08:44:57 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-12-15 01:57:29 -0500
commit8af3d8d5bc75914a01fe41839474902f2c6b79b9 (patch)
tree1aa10850f0fd2551a9036c87edc7b6efccf25b72 /drivers
parentcd6dbb038a191b1bea34819de547f66a2187e309 (diff)
[SCSI] fusion: ensure NUL-termination of MptCallbacksName elements
Using strlcpy instead of memcpy makes the strlen() calls superfluous and also ensures zero-termination of the copied string. At the same time get rid of the magic constant 50. Actually, I can't see why copying the callback name is necessary instead of simply storing a pointer to it (just like to the callback function itself), but that goes beyond the scope of this fix. Signed-off-by: Ferenc Wagner <wferi@niif.hu> Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/message/fusion/mptbase.c7
-rw-r--r--drivers/message/fusion/mptbase.h1
2 files changed, 5 insertions, 3 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index e9c6a6047a00..a7dc4672d996 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -115,7 +115,8 @@ module_param(mpt_fwfault_debug, int, 0600);
115MODULE_PARM_DESC(mpt_fwfault_debug, 115MODULE_PARM_DESC(mpt_fwfault_debug,
116 "Enable detection of Firmware fault and halt Firmware on fault - (default=0)"); 116 "Enable detection of Firmware fault and halt Firmware on fault - (default=0)");
117 117
118static char MptCallbacksName[MPT_MAX_PROTOCOL_DRIVERS][50]; 118static char MptCallbacksName[MPT_MAX_PROTOCOL_DRIVERS]
119 [MPT_MAX_CALLBACKNAME_LEN+1];
119 120
120#ifdef MFCNT 121#ifdef MFCNT
121static int mfcounter = 0; 122static int mfcounter = 0;
@@ -717,8 +718,8 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass, char *func_name)
717 MptDriverClass[cb_idx] = dclass; 718 MptDriverClass[cb_idx] = dclass;
718 MptEvHandlers[cb_idx] = NULL; 719 MptEvHandlers[cb_idx] = NULL;
719 last_drv_idx = cb_idx; 720 last_drv_idx = cb_idx;
720 memcpy(MptCallbacksName[cb_idx], func_name, 721 strlcpy(MptCallbacksName[cb_idx], func_name,
721 strlen(func_name) > 50 ? 50 : strlen(func_name)); 722 MPT_MAX_CALLBACKNAME_LEN+1);
722 break; 723 break;
723 } 724 }
724 } 725 }
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index b4d24dc081ae..76c05bc24cb7 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -89,6 +89,7 @@
89 */ 89 */
90#define MPT_MAX_ADAPTERS 18 90#define MPT_MAX_ADAPTERS 18
91#define MPT_MAX_PROTOCOL_DRIVERS 16 91#define MPT_MAX_PROTOCOL_DRIVERS 16
92#define MPT_MAX_CALLBACKNAME_LEN 49
92#define MPT_MAX_BUS 1 /* Do not change */ 93#define MPT_MAX_BUS 1 /* Do not change */
93#define MPT_MAX_FC_DEVICES 255 94#define MPT_MAX_FC_DEVICES 255
94#define MPT_MAX_SCSI_DEVICES 16 95#define MPT_MAX_SCSI_DEVICES 16