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, 24 Sep 2012 17:06:04 +0200
From:	Michal Nazarewicz <mpn@...gle.com>
To:	George Spelvin <linux@...izon.com>, linux@...izon.com,
	vda.linux@...glemail.com
Cc:	hughd@...gle.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] lib: vsprintf: Optimize put_dec_trunc8

On Mon, Sep 24 2012, George Spelvin wrote:
> Michal Nazarewicz <mpn@...gle.com> wrote:
>> static noinline_for_stack
>> char *put_dec_trunc8(char *buf, unsigned r) {
>> 	unsigned q;
>> 
>> 	if (r > 10000) {
>> 		do {
>> 			q = r + '0';
>> 			r = (r * (uint64_t)0x1999999a) >> 32;
>> 			*buf++ = q - 10 * r;
>> 		} while (r >= 10000);
>> 		if (r == 0)
>> 			return buf;
>> 	}
>> 
>> 	q      = (r * 0x199a) >> 16;
>> 	*buf++ = (r - 10 * q)  + '0'; /* 6 */
[...]
>> 	return buf;
>> }
>
> Two bugs:
>
> 1) The initial "(r > 10000)" should be >=.
>    If you let r == 10000 through to the remaining code, you'll get
>    ":000".

Obviously... ;)

>
> 2) The "r == 0" test isn't necessary.
>    Given that the loop divides r by 10 each time, r >= 10000 at the
>    beginning implies r >= 1000 at the end, so 1000 <= r < 10000
>    when the loop exits.

Yeah, I've just figured that out. :]
-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@...gle.com>--------------ooO--(_)--Ooo--

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ