diff options
author | Dan Carpenter <error27@gmail.com> | 2011-06-15 13:03:05 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-06-23 20:08:11 -0400 |
commit | 60d645a4e9e7e7ddc20e534fea82aa4e6947f911 (patch) | |
tree | 656848db8b14b92993df040058df24ce7012cb8b /drivers/target/target_core_device.c | |
parent | 5eff5be0b1993f4291f2b8c6d035b408010f96c5 (diff) |
target: Fix incorrect strlen() NULL terminator checks
This patch fixes a number of cases in target core using an incorrectly
if (strlen(foo) > SOME_MAX_SIZE)
As strlen() returns the number of characters in the string not counting
the NULL character at the end. So if you do something like:
char buf[10];
if (strlen("0123456789") > 10)
return -ETOOLONG;
snprintf(buf, 10, "0123456789");
printf("%s\n", buf);
then the last "9" gets chopped off and only "012345678" is printed.
Plus I threw in one small related cleanup.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_device.c')
-rw-r--r-- | drivers/target/target_core_device.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index f8d8af7a0d41..ba698ea62bb2 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -1431,7 +1431,7 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl( | |||
1431 | struct se_lun_acl *lacl; | 1431 | struct se_lun_acl *lacl; |
1432 | struct se_node_acl *nacl; | 1432 | struct se_node_acl *nacl; |
1433 | 1433 | ||
1434 | if (strlen(initiatorname) > TRANSPORT_IQN_LEN) { | 1434 | if (strlen(initiatorname) >= TRANSPORT_IQN_LEN) { |
1435 | printk(KERN_ERR "%s InitiatorName exceeds maximum size.\n", | 1435 | printk(KERN_ERR "%s InitiatorName exceeds maximum size.\n", |
1436 | TPG_TFO(tpg)->get_fabric_name()); | 1436 | TPG_TFO(tpg)->get_fabric_name()); |
1437 | *ret = -EOVERFLOW; | 1437 | *ret = -EOVERFLOW; |