Skip to contentSkip to conversation

tcm_vhost: another strlen() off by one

PATCH In review Dan Carpenter 2 participants 2 messages Jul 13, 2012 – Jul 14, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcm_vhost: another strlen() off by one

strlen() doesn't count the NUL terminator. I missed this one in the patches I sent yesterday.

drivers/vhost/tcm_vhost.c +1 -1
index 29850cb..ea72198 100644
@@ -1424,7 +1424,7 @@ static struct se_wwn *tcm_vhost_make_tport(
 	return ERR_PTR(-EINVAL);
 
 check_len:
-	if (strlen(name) > TCM_VHOST_NAMELEN) {
+	if (strlen(name) >= TCM_VHOST_NAMELEN) {
 		pr_err("Emulated %s Address: %s, exceeds"
 			" max: %d\n", name, tcm_vhost_dump_proto_id(tport),
 			TCM_VHOST_NAMELEN);
#1 lore raw
Quoted 10 lines · Dan Carpenter

strlen() doesn't count the NUL terminator. I missed this one in the patches I sent yesterday.

drivers/vhost/tcm_vhost.c +0 -0
index 29850cb..ea72198 100644

drivers/vhost/tcm_vhost.c static struct se_wwn *tcm_vhost_make_tport( · line 1430

Quoted 8 lines
drivers/vhost/tcm_vhost.c +1 -1
@@ -1424,7 +1424,7 @@ static struct se_wwn *tcm_vhost_make_tport(
 	return ERR_PTR(-EINVAL);
 
 check_len:
-	if (strlen(name) > TCM_VHOST_NAMELEN) {
+	if (strlen(name) >= TCM_VHOST_NAMELEN) {
 		pr_err("Emulated %s Address: %s, exceeds"
 			" max: %d\n", name, tcm_vhost_dump_proto_id(tport),
 			TCM_VHOST_NAMELEN);

Applied + squashed into the initial merge commit in for-next-merge.

Thanks DanC!

--nab