Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sun, 5 Jun 2022 00:55:48 +0600
From: NRK <>
Subject: Re: [PATCH] fix undefined behavior from large shifts

On Sat, Jun 04, 2022 at 02:16:36PM -0400, Rich Felker wrote:
> Indeed, musl code assumes int is at least 32-bit since it assumes the
> class of ABIs it supports.

Sorry, wasn't aware of that.

On Sat, Jun 04, 2022 at 06:04:15PM +0000, Pascal Cuoq wrote:
> If it were a goal to support 16-bit ints in musl, then your patch
> would still have UB by shifting a 1 into the sign bit with
> {h,n}[2]<<8, which in C is a form of signed arithmetic overflow (the
> C++ standard makes a special case for this situation but the C
> standard doesn't).

That makes sense. I misunderstood what the first cast was doing and
thought it was protection against int being 16bits.

Thanks for the replies and sorry for the trouble!


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.