From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A1B593858036 for ; Thu, 25 Nov 2021 14:09:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A1B593858036 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637849377; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=PYyV2x8jddfKhHYukqcpeNs9//I2okyMmf3P7pEi9NI=; b=dFr7/IT3lWpS7vNLIGtwki8B9fmBLzhv8m6VcX1w07hrPt7HxskR+1zRd3u9uDLb5YMGfD ZwDnOFwlD4VKeH4OciJSU96pf7BkNNBbu+cP1NIA17UL2dHBibLNiugWG2aP9ZMncFwng6 /xPtw8wP+83ZWCCze+ynlMznWAm5O6s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-147-555kY0pDOjOc7-fUtqfLGA-1; Thu, 25 Nov 2021 09:09:35 -0500 X-MC-Unique: 555kY0pDOjOc7-fUtqfLGA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0896B612CF for ; Thu, 25 Nov 2021 14:09:35 +0000 (UTC) Received: from calimero.vinschen.de (ovpn-112-13.ams2.redhat.com [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CEF476C350 for ; Thu, 25 Nov 2021 14:09:34 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 586DEA80D44; Thu, 25 Nov 2021 15:09:33 +0100 (CET) Date: Thu, 25 Nov 2021 15:09:33 +0100 From: Corinna Vinschen To: newlib@sourceware.org Subject: Re: [PATCH] ldtoa: Fix insufficient valid output digits for "%f" format. Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: newlib@sourceware.org References: <20211125120207.258-1-takashi.yano@nifty.ne.jp> MIME-Version: 1.0 In-Reply-To: <20211125120207.258-1-takashi.yano@nifty.ne.jp> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vinschen@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Nov 2021 14:09:38 -0000 Hi Takashi, looks good, but I see a potential problem at one point: On Nov 25 21:02, Takashi Yano wrote: > + limit now, either ndec (<= NDEC) or NDEC_SML, depending on ndigits. */ > + int ndec; > + if (mode == 3) /* %f */ > + { > + int expon = (e[NE - 1] & 0x7fff) - (EXONE - 1); /* exponent part */ > + /* log2(10) approximately 485/146 */ > + ndec = expon * 146 / 485 + ndigits; We have targets with sizeof(int) == 2. If expon is any number up to 0x7fff, multiplying it with 146 will overflow. Using __int32_t for expon should be safer. Thanks, Corinna