From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from slategray.cherry.relay.mailchannels.net (slategray.cherry.relay.mailchannels.net [23.83.223.169]) by sourceware.org (Postfix) with ESMTPS id 9F6E93858C20 for ; Thu, 1 Feb 2024 21:11:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F6E93858C20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9F6E93858C20 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=23.83.223.169 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1706821881; cv=pass; b=koRLrkbt+gm9/qH9RU4sV4wBLXua9mHlOpjMnYW3k1/Fjq2PhrZ13YWVrxqeJ3l6SP8jp0C0J/fz8Ggl/CPm4xPVeGJQLKeNFgluorBvkYjy6kdy4SRtyS971AJSFiGBwANyaD9rSNx5/QJBP1TSMsS+JNwPptWe5LPAMjjx6AQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1706821881; c=relaxed/simple; bh=kvqDyoEuxzNwWc/R3cOZQWB1oHTdijGJmPeY9bcnw9s=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=lUteWkKrEj6HtJ2aDaI/49uLluGPLCWJK+ApbQ1Pqx2ZDuh7Olfo/FPbPYZky25XzdwumrpmKFWquRNEUC2ClDPOZde3VkkTQgNlEgz1gjnqTXte5+AFTCH6Pgf4xG3SP4p3zXpQDBBP5Rcf/v2YuYc1+I5kFqXvZTc8rgq3QVE= ARC-Authentication-Results: i=2; server2.sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6E9B590315A; Thu, 1 Feb 2024 21:11:18 +0000 (UTC) Received: from pdx1-sub0-mail-a206.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 051879035D5; Thu, 1 Feb 2024 21:11:18 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1706821878; a=rsa-sha256; cv=none; b=FgqTaI6GuEogfkYT83xENeailVbBUCszT2M4XaZ7NRy44tRPOb3x+yH916k9JFigKHYQfk R9XbcQD331vXAe70bezHlQhigygOFvEFaHRMRjjIWHmp6DDSLgxPAfy7kEcGo5kzt+g9Cr P1tcJFnyUm0Ma5/4DUuQv/AsPfD3kvOSQM3ZZwDd6A44nzDXVclrG2j1hkkkrtzGbcNnc0 S4IAM/bcjXrTDXmrp4dCJxl0TI64wom71jFJnrfSVhjn3mFojDi0z5XkgfY8P4oVbl9uy3 4tZgbrUU8185TEV/yK0YwZ0yRP9h2Ttk8KWvxyW4vW6y9fQQTyNnCDMGzRIMpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1706821878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/0FtL17FRZ/qdqyjrsGgdtLfu6iGjbKlvgcBLZOkuAg=; b=0xhGDb2gv0i4o5PhPdOtYjlH/dgYzX6jklHN3Kqpn0YKeGSiFSuGki2RD1gQ/ayuho5Tq1 dbASehZlvlNtRaR6Dmer9OsBM6e+pPSKtK84BAmaUs1249HlyVYgtdtuJnjNesGd19Wr/J Y4JEgdhjjh1HQei2wJjOwba7pspGGCmSCrSwik1ilp78UXgXpOtGLt+/BHGKWvEchek49D ARYxKODlQC5YGPtAyZFS9b2MxjAIEVR22NhggCcRjC3fCeJoKINAM9m3PaenTxApsjnSQA cKVh3qildtpvA73QDBQc2xLuf5AOAc51rFa78UJNZigGeSQl4K+7HUpqi72VWw== ARC-Authentication-Results: i=1; rspamd-6bdc45795d-g5gfr; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Eight-Lettuce: 13f12bf53a02ef7f_1706821878298_1196811150 X-MC-Loop-Signature: 1706821878298:1685802519 X-MC-Ingress-Time: 1706821878298 Received: from pdx1-sub0-mail-a206.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.100.214.50 (trex/6.9.2); Thu, 01 Feb 2024 21:11:18 +0000 Received: from [192.168.0.182] (unknown [76.68.24.30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a206.dreamhost.com (Postfix) with ESMTPSA id 4TQs5d2PFWz6d; Thu, 1 Feb 2024 13:11:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1706821877; bh=/0FtL17FRZ/qdqyjrsGgdtLfu6iGjbKlvgcBLZOkuAg=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=hZxgwZC5S8D8gIVZ8gFbk7GwNqEv9Jm3ZbDYZQA5sHLnHHP27kCEnJX+WWQDo34bz wK9sB06+LYrH7ra24A1B4UPkXT1QMGTinqynQuAQ2Iov2jaXtxUwjTGPCfpOFF9CbQ WLbO8OteR2eZ+3A5LivjdXKg2nc+Sreca1tlwwupggBZOMDEindiVYOSc6vrd2t23t e7N0TFaELxfQ2Y4HVr9CF8dgsqyrMJYvVcZ8O9F9uXFP8T+jqTEkjddHzFIFmrZM2u it8C+KZ50w14Lw23lB8/t1JbT0dcGlhxZlZBuKXWEY1/J2pK7BxgYyWNV2vlps5DRX ucxBnZV4lz32g== Message-ID: <7234533a-c8dd-4114-aa64-d4af3b138a3a@gotplt.org> Date: Thu, 1 Feb 2024 16:11:06 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: New GNU C Library (glibc) security flaw reported on 30 Jan 2024 Content-Language: en-US To: Paul Eggert , Vincent Lefevre , Xi Ruoyao , Adhemerval Zanella Netto , Turritopsis Dohrnii Teo En Ming , "libc-alpha@sourceware.org" , "ceo@teo-en-ming-corp.com" References: <20240131145555.GB2102@cventin.lip.ens-lyon.fr> <96521764f4636c9ea3f3089f369975c12fa8be77.camel@xry111.site> <20240201005155.GF3044@qaa.vinc17.org> <20240201090721.GH3044@qaa.vinc17.org> <5ea9eabb-f047-490f-abe9-43630d79c395@cs.ucla.edu> From: Siddhesh Poyarekar In-Reply-To: <5ea9eabb-f047-490f-abe9-43630d79c395@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3036.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_MANYTO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2024-02-01 14:55, Paul Eggert wrote: > From 8ff74efcc11a77e221808293ed390faf6dea86fe Mon Sep 17 00:00:00 2001 > From: Paul Eggert > Date: Thu, 1 Feb 2024 11:52:46 -0800 > Subject: [PATCH] stdlib: fix qsort example in manual > > * manual/search.texi (Comparison Functions, Array Sort Function): > Sort an array of long ints, not doubles, to avoid hassles > with NaNs. > --- > manual/search.texi | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) Reviewed-by: Siddhesh Poyarekar > > diff --git a/manual/search.texi b/manual/search.texi > index ffaadc46f5..db577a5332 100644 > --- a/manual/search.texi > +++ b/manual/search.texi > @@ -35,19 +35,22 @@ second, zero if they are ``equal'', and positive if the first argument > is ``greater''. > > Here is an example of a comparison function which works with an array of > -numbers of type @code{double}: > +numbers of type @code{long int}: > > @smallexample > int > -compare_doubles (const void *a, const void *b) > +compare_long_ints (const void *a, const void *b) > @{ > - const double *da = (const double *) a; > - const double *db = (const double *) b; > + const long int *la = a; > + const long int *lb = b; > > - return (*da > *db) - (*da < *db); > + return (*la > *lb) - (*la < *lb); > @} > @end smallexample > > +(The code would have to be more complicated for an array of @code{double}, > +to handle NaNs correctly.) > + > The header file @file{stdlib.h} defines a name for the data type of > comparison functions. This type is a GNU extension. > > @@ -183,16 +186,16 @@ in the array before making some comparisons. The only way to perform > a stable sort with @code{qsort} is to first augment the objects with a > monotonic counter of some kind. > > -Here is a simple example of sorting an array of doubles in numerical > +Here is a simple example of sorting an array of @code{long int} in numerical > order, using the comparison function defined above (@pxref{Comparison > Functions}): > > @smallexample > @{ > - double *array; > - int size; > + long int *array; > + size_t nmemb; > @dots{} > - qsort (array, size, sizeof (double), compare_doubles); > + qsort (array, nmemb, sizeof *array, compare_long_ints); > @} > @end smallexample > > -- > 2.40.1