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.3 required=5.0 tests=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 3720 invoked from network); 13 Apr 2022 14:05:49 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 13 Apr 2022 14:05:49 -0000 Received: (qmail 32239 invoked by uid 550); 13 Apr 2022 14:05:46 -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 32207 invoked from network); 13 Apr 2022 14:05:45 -0000 Date: Wed, 13 Apr 2022 10:05:33 -0400 From: Rich Felker To: Natanael Copa Cc: "Gary E. Miller" , musl@lists.openwall.com Message-ID: <20220413140532.GT7074@brightrain.aerifal.cx> References: <20220412134355.59bd920e@spidey.rellim.com> <20220413142432.311e20f5@ncopa-desktop.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220413142432.311e20f5@ncopa-desktop.lan> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] *strerror_r() bug in musl On Wed, Apr 13, 2022 at 02:24:32PM +0200, Natanael Copa wrote: > On Tue, 12 Apr 2022 13:43:55 -0700 > "Gary E. Miller" wrote: > > > Yo All! > > Hi! > > > > > I'm new to the list. I;ve been trying to report a musl bug on #musl since > > last Friday, but no one seems to live there. > > > > musl (all versions) has a bug in strerror_r(). > > > > The musl reference manual says of _GNUSOURCE: > > > > _GNU_SOURCE (or _ALL_SOURCE) > > > > Adds everything above, plus interfaces modeled after GNU libc > > extensions and interfaces for making use of Linux-specific features. > > > > I take that to mean that when _GNU_SOURCE is used to compile code with musl > > that the results will behave as GNU libc (glinc). > > Well, as other has mentioned. GNU libc has a non-compliant version of > strerror_r. > > .... > > > When _GNU_SOURCE is defined with glibc, then strerror_r() returns a char *. > > I have met this in multiple places the last decade. The usual way to > fix it is to also check for GNU libc in addition to _GNU_SOURCE. > > #if defined (__GLIBC__) && defined (_GNU_SOURCE) > /* non-standard GLIBC exception */ > #else > /* standard behavior for everything else */ > #endif That, or probe for the signature with a configure-style check and use the result of that, as in #ifdef HAVE_GNU_STRERROR_R // handle the GNU version #else // code written to the standard #endif or, even better, wrapping strerror_r in a translation unit that begins with #undef _GNU_SOURCE #define _POSIX_C_SOURCE 200809L or similar so that you always get the standard one, and calling your wrapper instead. Rich