Commit 8af3d8d5 authored by Ferenc Wagner's avatar Ferenc Wagner Committed by James Bottomley

[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: default avatarFerenc Wagner <wferi@niif.hu>
Acked-by: default avatar"Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent cd6dbb03
...@@ -115,7 +115,8 @@ module_param(mpt_fwfault_debug, int, 0600); ...@@ -115,7 +115,8 @@ module_param(mpt_fwfault_debug, int, 0600);
MODULE_PARM_DESC(mpt_fwfault_debug, MODULE_PARM_DESC(mpt_fwfault_debug,
"Enable detection of Firmware fault and halt Firmware on fault - (default=0)"); "Enable detection of Firmware fault and halt Firmware on fault - (default=0)");
static char MptCallbacksName[MPT_MAX_PROTOCOL_DRIVERS][50]; static char MptCallbacksName[MPT_MAX_PROTOCOL_DRIVERS]
[MPT_MAX_CALLBACKNAME_LEN+1];
#ifdef MFCNT #ifdef MFCNT
static int mfcounter = 0; static int mfcounter = 0;
...@@ -717,8 +718,8 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass, char *func_name) ...@@ -717,8 +718,8 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass, char *func_name)
MptDriverClass[cb_idx] = dclass; MptDriverClass[cb_idx] = dclass;
MptEvHandlers[cb_idx] = NULL; MptEvHandlers[cb_idx] = NULL;
last_drv_idx = cb_idx; last_drv_idx = cb_idx;
memcpy(MptCallbacksName[cb_idx], func_name, strlcpy(MptCallbacksName[cb_idx], func_name,
strlen(func_name) > 50 ? 50 : strlen(func_name)); MPT_MAX_CALLBACKNAME_LEN+1);
break; break;
} }
} }
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
*/ */
#define MPT_MAX_ADAPTERS 18 #define MPT_MAX_ADAPTERS 18
#define MPT_MAX_PROTOCOL_DRIVERS 16 #define MPT_MAX_PROTOCOL_DRIVERS 16
#define MPT_MAX_CALLBACKNAME_LEN 49
#define MPT_MAX_BUS 1 /* Do not change */ #define MPT_MAX_BUS 1 /* Do not change */
#define MPT_MAX_FC_DEVICES 255 #define MPT_MAX_FC_DEVICES 255
#define MPT_MAX_SCSI_DEVICES 16 #define MPT_MAX_SCSI_DEVICES 16
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment