lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4C8E9C95.8070201@infradead.org>
Date:	Mon, 13 Sep 2010 18:50:13 -0300
From:	Mauro Carvalho Chehab <mchehab@...radead.org>
To:	Joe Perches <joe@...ches.com>
CC:	linux-kernel@...r.kernel.org, mjpeg-users@...ts.sourceforge.net,
	linux-media@...r.kernel.org
Subject: Re: [PATCH 07/25] drivers/media: Use static const char arrays

Em 13-09-2010 16:47, Joe Perches escreveu:
> Signed-off-by: Joe Perches <joe@...ches.com>
> ---
>  drivers/media/video/zoran/zoran_device.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/video/zoran/zoran_device.c b/drivers/media/video/zoran/zoran_device.c
> index 6f846ab..ea8a1e9 100644
> --- a/drivers/media/video/zoran/zoran_device.c
> +++ b/drivers/media/video/zoran/zoran_device.c
> @@ -1470,8 +1470,7 @@ zoran_irq (int             irq,
>  		    (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS ||
>  		     zr->codec_mode == BUZ_MODE_MOTION_COMPRESS)) {
>  			if (zr36067_debug > 1 && (!zr->frame_num || zr->JPEG_error)) {
> -				char sc[] = "0000";
> -				char sv[5];
> +				char sv[sizeof("0000")];
>  				int i;
>  
>  				printk(KERN_INFO
> @@ -1481,7 +1480,7 @@ zoran_irq (int             irq,
>  				       zr->jpg_settings.field_per_buff,
>  				       zr->JPEG_missed);
>  
> -				strcpy(sv, sc);
> +				strcpy(sv, "0000");
>  				for (i = 0; i < 4; i++) {
>  					if (le32_to_cpu(zr->stat_com[i]) & 1)
>  						sv[i] = '1';

This looks ugly to me, as someone may change the string at strcpy and not change at sizeof.
Could you please try to work on a better alternative?

The cleaner way seems to be to rewrite it as:

#define BUZ_MODE_STAT	4

char sv[BUZ_MODE_STAT + 1];
...
for (i = 0; i < BUZ_MODE_STAT; i++)
	sv[i] = (le32_to_cpu(zr->stat_com[i]) & 1)? '1' : '0';



Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ