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 13:55:23 +1000
From:	Stephen Rothwell <sfr@...b.auug.org.au>
To:	Pierre Carrier <pierre@...tify.com>
Cc:	Joe Perches <joe@...ches.com>,
	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,

On Mon, 7 May 2012 04:20:18 +0200 Pierre Carrier <pierre@...tify.com> wrote:
>
> On Mon, May 7, 2012 at 3:59 AM, Joe Perches <joe@...ches.com> wrote:
> > If you do this, why not change 0-7 instead of just 0?
> 
> Consistency with POSIX *printf.
> 
> "#: Specifies that the value is to be converted to an alternative
> form. For o conversion, it increases the precision (if necessary) to
> force the first digit of the result to be zero."
> -- http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html
> 
> % cat octal.c;gcc -o octal octal.c;./octal
> #include <stdio.h>
> void main() {
>         int i;
>         for (i=0;i<10;i++) printf("%#o ", i);
>         puts("");
> }
> 0 01 02 03 04 05 06 07 010 011

Yes, if we are going to follow anything, then it may as well be that.

However just to add more mess, the next part of that section of the standard says:

"For x or X conversion specifiers, a non-zero result shall have 0x (or
0X) prefixed to it."

so we should also do:

0 0x1 ...

However, I think we expect 0x0, so changing it is, I think, unnecessary.

-- 
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