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>
This commit is contained in:
committed by
Nicholas Bellinger
parent
5eff5be0b1
commit
60d645a4e9
@@ -1431,7 +1431,7 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
|
||||
struct se_lun_acl *lacl;
|
||||
struct se_node_acl *nacl;
|
||||
|
||||
if (strlen(initiatorname) > TRANSPORT_IQN_LEN) {
|
||||
if (strlen(initiatorname) >= TRANSPORT_IQN_LEN) {
|
||||
printk(KERN_ERR "%s InitiatorName exceeds maximum size.\n",
|
||||
TPG_TFO(tpg)->get_fabric_name());
|
||||
*ret = -EOVERFLOW;
|
||||
|
||||
Reference in New Issue
Block a user