diff mbox

[-next] tcm_vhost: another strlen() off by one

Message ID 20120713104547.GA31435@elgon.mountain (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter July 13, 2012, 10:45 a.m. UTC
strlen() doesn't count the NUL terminator.  I missed this one in the
patches I sent yesterday.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Nicholas A. Bellinger July 14, 2012, 10:21 p.m. UTC | #1
On Fri, 2012-07-13 at 13:45 +0300, Dan Carpenter wrote:
> strlen() doesn't count the NUL terminator.  I missed this one in the
> patches I sent yesterday.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
> index 29850cb..ea72198 100644
> --- a/drivers/vhost/tcm_vhost.c
> +++ b/drivers/vhost/tcm_vhost.c
> @@ -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

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
index 29850cb..ea72198 100644
--- a/drivers/vhost/tcm_vhost.c
+++ b/drivers/vhost/tcm_vhost.c
@@ -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);