From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1061 invoked from network); 4 Jun 2022 18:56:09 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 4 Jun 2022 18:56:09 -0000 Received: (qmail 15718 invoked by uid 550); 4 Jun 2022 18:56:07 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 15684 invoked from network); 4 Jun 2022 18:56:06 -0000 X-Virus-Scanned: SPAM Filter at disroot.org Date: Sun, 5 Jun 2022 00:55:48 +0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1654368954; bh=sXue1KknFxphMybjDk356ox+OdkyiVFgUlRo2AUOohk=; h=Date:From:To:Subject:References:In-Reply-To; b=XUnr0pgzHS+uTLBpEzFa1XOOflL/VlVit4mSO6H7Mp4zdmbSWtUVjRIIoPi8PZqH8 D+PG4orzlV7Ydv60QKxDMwV3ecAyh7Ojl9x/vwugRKMZ7tdozyHb8QHnNUdXEaGNT6 Y4pDiPTc65PDvEwLTg+YBPe2CfQ7kvCYi+NctTDPlRr2cRDHdd8JDkBs/eBA1UYMDX pCwfSR+/wVD4Y0QNTXZwR6L1CtPF4RMTUrpRYM1r78EzdqQvBSr+1a+JxbIFdyLa6P w7Hm4sx4+iXSG7DQJtWRbp8LBeBRx8U+OBem1ibb29qDt+BAhhAjd4jfvUc/MK3EJb S/OqCaNIL8l/Q== From: NRK To: musl@lists.openwall.com Message-ID: <20220604185548.ulek63neaq33lqzc@gen2.localdomain> References: <20220604172550.uf7vboamzar4etk3@gen2.localdomain> <20220604181636.GB7074@brightrain.aerifal.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220604181636.GB7074@brightrain.aerifal.cx> Subject: Re: [musl] [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! - NRK