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=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32049 invoked from network); 30 Oct 2022 17:11:25 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 30 Oct 2022 17:11:25 -0000 Received: (qmail 1944 invoked by uid 550); 30 Oct 2022 17:11:21 -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 1909 invoked from network); 30 Oct 2022 17:11:21 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1667149869; bh=oLS0F/rvMXXjz/Sq+69NlWE1p/hvPWK2PrixD3hDmkQ=; h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To; b=OZxmogQSr2VMc993OAh7akutBhkShoXxTQWMPnsP2bdfPQ+Eb2BKiLEd2hs+YGxE4 HrB4XbqxuhwRRfY5FyVicbFLCOin/hVZeol2IHG6DaNPMvxJnUmZd6wFi4/tnOdSnu 7MpfQUpyLMJ63JwDO97ckPNSPxYfgD39rnhdCzHkEK2jUCNesZ7z8tF6CCvuD0QN4q lMKjzPMLBzGGLBFyssBDv1yqVJlAJoXrcayJaCjfxmCYC2PJ/z9C6K2tjpcUziJsFJ X12QSPJm7/edrx9NYw2lxNFyneqXNNztw+wvAIyJ6jeksxjD7FJ/lZn8Gu8ce4MgtH 3cRJQFXLhckFw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Date: Sun, 30 Oct 2022 18:11:07 +0100 From: Markus Wichmann To: musl@lists.openwall.com Message-ID: <20221030171107.GA1992@voyager> References: <1903ff21f49146998d843cc2860f7166@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1903ff21f49146998d843cc2860f7166@huawei.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Provags-ID: V03:K1:N8HZVMlCyD+wGqRMYLyqkw5Ub4W4cLcaxD9oyCFr9tGGXNFYH/5 g6p251jGz6nJrD4CMNC211/Cds4lwRdI9n1w9bIXk+RTojl+G2nGcvEExVDusb0grzxPR41 Rhz3TGE9dzF/0N563RrkbdI6H758b6FuThZ6RvXOu7IpumCoyLrUt7es6QdgvkH7nNmNMiW A5aJHvE7EYaNzsI/q0tvg== UI-OutboundReport: notjunk:1;M01:P0:2Si+DpSVvTQ=;O7rqf1jvdNrOro6sR50p8dfjpbr 8N7KG10uxcM131ozl050f6t+8d43xML8HtUzmPm9qx1teAC1/RbrAGQzmpifP9mgyuhNLm3Fk 9qexaFtEXksqBkszQ0L9V7W9kecb9UU+egcEmBBjdhB69VxlYpp6QuZ4afdXZfdpClTaUxwxH SOrZH4eFPmFYld7HGrBffw06un+NBRtB2DCiIwSxfeH9nwFJncTEtosr8MpPusgkTjWVtA4UZ YmNuKCGbmxlaJPx4u++c4Zx/Qa4HfqJn9yMuVZ+eAx3UdD7jB5aFN4tEKOZ/V04oJIEaealOn OMC5Iqxz08E4LzrIEjCU+wqlL38v8hIhWmUk3LbBaEPgIpMOfm+GQCwID7BZS/Yo6Z1/a3Kn3 ynpMN3qttLXG/TGp9ZbN5diT5MqZ9Gj9nI8cm0a8haCjVHp53vyZiZTfs8BaAV5B4jrNEONhH ZXX1QyrhCXSkzEzu78OoWJOk36VnaKUq/IJVbuzubNIVmOhOg1roKtutFeU0H9n+UFYsQTxaI Td8z5skico8VjREPAXTLl3BDx6AYfRCeRWd+908KxQ136zx1wkHFQ+np35HS5R4pIinH89jeM u2Kg2Ee+x8DUYPPiNN/SyRLUvGAoJBugVOsWCV76TOfC8O7z9316JJZsvCtUd9WZBQo1+vlU4 Wz0sRZsn2L/SvZIZsB5gRpkNrPr65alVFAKXc+m4W7P8bHsI+vpGB7kdi8c3N/oVtq0GTdwZb FwA6cm8r95wZZsCj/T4Ph6nYlc6P3xeCyMm1z4NiHpKtqI0dYFV+Bm8lQoZ/eVLo8DBymUDx+ NYwPPmyIn9RfctiEBIbsO719EVfQmEWjdUpYp96ZTdJoLM5Ayz2gliyc7veYw15a2DIDA84u4 Ofq9C6tfynKnrVEMU2y+4VA6l56djvANrL2BsBD8YbfTqAIYJszrs4WC0316JocBvGZ/aP+/R 3dqN0A== Content-Transfer-Encoding: quoted-printable Subject: Re: [musl] Question on 2b2c8aafce9d80f9d58652643538f4d58e82b856 On Sun, Oct 30, 2022 at 06:29:54AM +0000, puwenxu wrote: > Dear maintainer, I'm using musl 1.2.3.0 now. When I was running some > test case codes for musl, I found there may be a problem on > modification of 2b2c8aafce9d80f9d58652643538f4d58e82b856. As you can > see in the picture, this modification assign buf to orig. Then, the > orig will be assigned to buf again. If the original value of buf is > NULL, the latter value of the buf will be NULL. However, assign out to > buf will fail if buf is NULL. [cid:image001.png@01D8EC6C.12AE8540] I > have written a simple file to verification my opinion. The test code > and output is shown in the following picture. I think it may be better > to add a check for buf in this situation. > [cid:image002.png@01D8EC6C.12AE8540] > [cid:image003.png@01D8EC6C.12AE8540] Looking forward to your reply. > > > > Wish Pu OS Kernel Lab > Hi, as the others already said, please avoid images if text would also do. I do also note that it appears you Huawei people have a bee in your bonnet about NULL pointer checks. musl does not plaster over bad behavior. In the cases where a NULL pointer argument would be dereferenced, it was undefined behavior to give a NULL pointer argument in the first place. I do agree that programs need to be prevented from dereferencing NULL pointers, but the place to do so is after creating the pointers and before handing it to an API that does not accept NULL pointers. And yes, it does suck that C is incapable of expressing the idea of a non-nullable pointer natively, but C is the language we're stuck with. Your test program only shows that by default, dereferencing the NULL pointer on Linux crashes. This is well-known, though not behavior you can rely upon since it can be overridden if you know how. In any case, having a pointer which ought to point at an object point to nothing is a logic error that needs to be rectified in the calling code. Just check your malloc() returns, it isn't that difficult! Ciao, Markus