mailing list of musl libc
 help / color / mirror / code / Atom feed
From: NRK <nrk@disroot.org>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] fix undefined behavior from large shifts
Date: Sun, 5 Jun 2022 00:55:48 +0600	[thread overview]
Message-ID: <20220604185548.ulek63neaq33lqzc@gen2.localdomain> (raw)
In-Reply-To: <20220604181636.GB7074@brightrain.aerifal.cx>

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!

- NRK

      reply	other threads:[~2022-06-04 18:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-04 17:25 NRK
2022-06-04 18:04 ` Pascal Cuoq
2022-06-04 18:16   ` Rich Felker
2022-06-04 18:55     ` NRK [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220604185548.ulek63neaq33lqzc@gen2.localdomain \
    --to=nrk@disroot.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).