All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 2/3 -next] tcm_vhost: strlen() doesn't count the terminator
@ 2012-07-12 14:48 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-07-12 14:48 UTC (permalink / raw)
  To: Michael S. Tsirkin, Nicholas Bellinger
  Cc: kernel-janitors, kvm, virtualization

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 <dan.carpenter@oracle.com>

diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
index d217bed..57d39c5 100644
--- a/drivers/vhost/tcm_vhost.c
+++ b/drivers/vhost/tcm_vhost.c
@@ -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;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch 2/3 -next] tcm_vhost: strlen() doesn't count the terminator
@ 2012-07-12 14:48 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-07-12 14:48 UTC (permalink / raw)
  To: Michael S. Tsirkin, Nicholas Bellinger
  Cc: kernel-janitors, kvm, virtualization

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 <dan.carpenter@oracle.com>

diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
index d217bed..57d39c5 100644
--- a/drivers/vhost/tcm_vhost.c
+++ b/drivers/vhost/tcm_vhost.c
@@ -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;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch 2/3 -next] tcm_vhost: strlen() doesn't count the terminator
  2012-07-12 14:48 ` Dan Carpenter
@ 2012-07-12 21:48   ` Nicholas A. Bellinger
  -1 siblings, 0 replies; 4+ messages in thread
From: Nicholas A. Bellinger @ 2012-07-12 21:48 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: target-devel, virtualization, kernel-janitors, kvm, Michael S. Tsirkin

On Thu, 2012-07-12 at 17:48 +0300, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
> index d217bed..57d39c5 100644
> --- a/drivers/vhost/tcm_vhost.c
> +++ b/drivers/vhost/tcm_vhost.c
> @@ -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!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 2/3 -next] tcm_vhost: strlen() doesn't count the terminator
@ 2012-07-12 21:48   ` Nicholas A. Bellinger
  0 siblings, 0 replies; 4+ messages in thread
From: Nicholas A. Bellinger @ 2012-07-12 21:48 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: target-devel, virtualization, kernel-janitors, kvm, Michael S. Tsirkin

On Thu, 2012-07-12 at 17:48 +0300, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
> index d217bed..57d39c5 100644
> --- a/drivers/vhost/tcm_vhost.c
> +++ b/drivers/vhost/tcm_vhost.c
> @@ -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!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-07-12 21:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-12 14:48 [patch 2/3 -next] tcm_vhost: strlen() doesn't count the terminator Dan Carpenter
2012-07-12 14:48 ` Dan Carpenter
2012-07-12 21:48 ` Nicholas A. Bellinger
2012-07-12 21:48   ` Nicholas A. Bellinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.