Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120613164546.GA23407@openwall.com>
Date: Wed, 13 Jun 2012 20:45:46 +0400
From: Solar Designer <solar@...nwall.com>
To: musl@...ts.openwall.com
Subject: Re: FreeSec crypt()

On Wed, Jun 13, 2012 at 10:56:03AM -0400, Rich Felker wrote:
> On Wed, Jun 13, 2012 at 05:18:07PM +0400, Solar Designer wrote:
> > > Note that even if the behavior were defined, this code seems to have
> > > different behavior for high bytes depending on the signedness of char.
...
> > Why would signedness of char matter
> > if the behavior of the signed char overflowing left shift were defined?
> 
> Well if char is signed, (char)0x80 << 1 is -256. If char is unsigned,
> (char)0x80 << 1 is 256.

Sure, but we had:

	const char *key;
	u_char *q;
	*q++ = *key << 1;

so while *key << 1 is either -256 or 256 (promoted to int or unsigned
int), those high bits get dropped on the assignment to *q anyway,
resulting in the same value there either way.  No?

Alexander

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.