tcm_vhost: strlen() doesn't count the terminator
Subsystems (4)
PATCH 2/3 tcm_vhost: strlen() doesn't count the terminator
We do snprintf() from "page" to a buffer with TCM_VHOST_NAMELEN characters so the current code will silently truncate the last character.
Signed-off-by Dan Carpenter <[email protected]>
drivers/vhost/tcm_vhost.c +1 -1
@@ -1254,7 +1254,7 @@ static ssize_t tcm_vhost_tpg_store_nexus(* the fabric protocol_id set in tcm_vhost_make_tport(), and call * tcm_vhost_make_nexus(). */ -if (strlen (page) >TCM_VHOST_NAMELEN ) { +if (strlen (page) >=TCM_VHOST_NAMELEN ) {pr_err ("Emulated NAA Sas Address: %s, exceeds" " max: %d\n" , page,TCM_VHOST_NAMELEN );return -EINVAL ;
Quoted 11 lines · Dan Carpenter
We do
snprintf()from "page" to a buffer withTCM_VHOST_NAMELENcharacters so the current code will silently truncate the last character.Signed-off-by Dan Carpenter <[email protected]>drivers/vhost/tcm_vhost.c +0
-0
drivers/vhost/tcm_vhost.c static ssize_t tcm_vhost_tpg_store_nexus( · line 1260
Quoted 8 lines
drivers/vhost/tcm_vhost.c +1
-1@@ -1254,7 +1254,7 @@ static ssize_t tcm_vhost_tpg_store_nexus(* the fabric protocol_id set in tcm_vhost_make_tport(), and call * tcm_vhost_make_nexus(). */ -if (strlen (page) >TCM_VHOST_NAMELEN ) { +if (strlen (page) >=TCM_VHOST_NAMELEN ) {pr_err ("Emulated NAA Sas Address: %s, exceeds" " max: %d\n" , page,TCM_VHOST_NAMELEN );return -EINVAL ;
Also applied. Thanks!