public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] target: change sprintf to snprintf
@ 2013-01-18 13:05 Dan Carpenter
  2013-01-18 19:36 ` Nicholas A. Bellinger
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2013-01-18 13:05 UTC (permalink / raw)
  To: Nicholas A. Bellinger; +Cc: linux-scsi, target-devel, kernel-janitors

"buf" is 128 characters and "vpd->device_identifier" is 256.  It makes
the static checkers complain.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Probably we should just raise VPD_TMP_BUF_SIZE to 300.

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index bd587b7..96b64d5 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -907,15 +907,18 @@ int transport_dump_vpd_ident(
 
 	switch (vpd->device_identifier_code_set) {
 	case 0x01: /* Binary */
-		sprintf(buf, "T10 VPD Binary Device Identifier: %s\n",
+		snprintf(buf, sizeof(buf),
+			"T10 VPD Binary Device Identifier: %s\n",
 			&vpd->device_identifier[0]);
 		break;
 	case 0x02: /* ASCII */
-		sprintf(buf, "T10 VPD ASCII Device Identifier: %s\n",
+		snprintf(buf, sizeof(buf),
+			"T10 VPD ASCII Device Identifier: %s\n",
 			&vpd->device_identifier[0]);
 		break;
 	case 0x03: /* UTF-8 */
-		sprintf(buf, "T10 VPD UTF-8 Device Identifier: %s\n",
+		snprintf(buf, sizeof(buf),
+			"T10 VPD UTF-8 Device Identifier: %s\n",
 			&vpd->device_identifier[0]);
 		break;
 	default:

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

* Re: [patch] target: change sprintf to snprintf
  2013-01-18 13:05 [patch] target: change sprintf to snprintf Dan Carpenter
@ 2013-01-18 19:36 ` Nicholas A. Bellinger
  2013-01-18 21:35   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Nicholas A. Bellinger @ 2013-01-18 19:36 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-scsi, target-devel, kernel-janitors

On Fri, 2013-01-18 at 16:05 +0300, Dan Carpenter wrote:
> "buf" is 128 characters and "vpd->device_identifier" is 256.  It makes
> the static checkers complain.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Applied to target-pending/for-next.

> Probably we should just raise VPD_TMP_BUF_SIZE to 300.

Also bumping up VPD_TMP_BUF_SIZE to 254 to match the usage with
INQUIRY_VPD_DEVICE_IDENTIFIER_LEN sized vpd->device_identifier[] below.

Thanks Dan!

--nab

> 
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index bd587b7..96b64d5 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -907,15 +907,18 @@ int transport_dump_vpd_ident(
>  
>  	switch (vpd->device_identifier_code_set) {
>  	case 0x01: /* Binary */
> -		sprintf(buf, "T10 VPD Binary Device Identifier: %s\n",
> +		snprintf(buf, sizeof(buf),
> +			"T10 VPD Binary Device Identifier: %s\n",
>  			&vpd->device_identifier[0]);
>  		break;
>  	case 0x02: /* ASCII */
> -		sprintf(buf, "T10 VPD ASCII Device Identifier: %s\n",
> +		snprintf(buf, sizeof(buf),
> +			"T10 VPD ASCII Device Identifier: %s\n",
>  			&vpd->device_identifier[0]);
>  		break;
>  	case 0x03: /* UTF-8 */
> -		sprintf(buf, "T10 VPD UTF-8 Device Identifier: %s\n",
> +		snprintf(buf, sizeof(buf),
> +			"T10 VPD UTF-8 Device Identifier: %s\n",
>  			&vpd->device_identifier[0]);
>  		break;
>  	default:

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

* Re: [patch] target: change sprintf to snprintf
  2013-01-18 19:36 ` Nicholas A. Bellinger
@ 2013-01-18 21:35   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2013-01-18 21:35 UTC (permalink / raw)
  To: Nicholas A. Bellinger; +Cc: linux-scsi, target-devel, kernel-janitors

On Fri, Jan 18, 2013 at 11:36:52AM -0800, Nicholas A. Bellinger wrote:
> On Fri, 2013-01-18 at 16:05 +0300, Dan Carpenter wrote:
> > "buf" is 128 characters and "vpd->device_identifier" is 256.  It makes
> > the static checkers complain.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> 
> Applied to target-pending/for-next.
> 
> > Probably we should just raise VPD_TMP_BUF_SIZE to 300.
> 
> Also bumping up VPD_TMP_BUF_SIZE to 254 to match the usage with
> INQUIRY_VPD_DEVICE_IDENTIFIER_LEN sized vpd->device_identifier[] below.
> 

It could still go over 254 because it's "T10 VPD Binary Device
Identifier: " plus INQUIRY_VPD_DEVICE_IDENTIFIER_LEN.  But I agree
that probably 254 is enough space.

regards,
dan carpenter

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

end of thread, other threads:[~2013-01-18 21:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-18 13:05 [patch] target: change sprintf to snprintf Dan Carpenter
2013-01-18 19:36 ` Nicholas A. Bellinger
2013-01-18 21:35   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox