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]
Date:	Mon, 7 May 2012 10:19:49 +1000
From:	Stephen Rothwell <sfr@...b.auug.org.au>
To:	Pierre Carrier <pierre@...tify.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] lib/vsprintf.c: "%#o",0 becomes '0' instead of '00'

Hi Pierre,

Thanks for doing this.  Comments below.

On Sat,  5 May 2012 16:32:30 +0200 Pierre Carrier <pierre@...tify.com> wrote:
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index abbabec..7129383 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -284,6 +284,7 @@ char *number(char *buf, char *end, unsigned long long num,
>  	char locase;
>  	int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10);
>  	int i;
> +	bool is_null = num == 0LL;

"num" is a number not a pointer, so I would call it "is_zero" (or just do
the comparisons explicitly below).

>  	/* locase = 0 or 0x20. ORing digits or letters with 'locase'
>  	 * produces same digits or (maybe lowercased) letters */
> @@ -353,9 +354,11 @@ char *number(char *buf, char *end, unsigned long long num,
>  	}
>  	/* "0x" / "0" prefix */
>  	if (need_pfx) {
> -		if (buf < end)
> -			*buf = '0';
> -		++buf;
> +		if (spec.base == 16 || !is_null) {
> +			if (buf < end)
> +				*buf = '0';
> +			++buf;
> +		}
>  		if (spec.base == 16) {
>  			if (buf < end)
>  				*buf = ('X' | locase);

There is also another earlier section that tests "need_pfx" that reduces
the field width.  You should fix that up as well.

-- 
Cheers,
Stephen Rothwell                    sfr@...b.auug.org.au
http://www.canb.auug.org.au/~sfr/

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ