Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <07FBEE99-778B-4A8C-B968-077B4515E000@ridiculousfish.com>
Date: Sat, 13 Apr 2024 09:00:19 -0700
From: Peter Ammon <corydoras@...iculousfish.com>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] Fix printf hex float formatting with precision

Good catch on the overflow. Yes, that patch looks correct to me and I
confirmed it fixes the issue on ARMv7.

> On Apr 12, 2024, at 4:33 PM, Rich Felker <dalias@...c.org> wrote:
> 
> On Fri, Apr 12, 2024 at 03:57:28PM -0400, Rich Felker wrote:
>> On Thu, Apr 11, 2024 at 06:17:25PM -0700, Peter Ammon wrote:
>>> if (p>=0 && p<(LDBL_MANT_DIG-1+3)/4) {
>>>    int re = LDBL_MANT_DIG-1-(p*4);
>>>    long double round = 1ULL<<re;
>> 
>> This expression overflows. re can be as large as 108 but 1ULL has
>> 64-bit type.
>> 
>> There's probably some reasonable way to write it that works for
>> reasonable sizes of long double (I think it's safe to assume IEEE quad
>> is the max that will ever be supported), but I presume I wrote it with
>> the original inefficient loop to be fully general to arbitrary
>> precision.
>> 
>> It could just be written to use scalbn, I think. At the time I
>> probably was trying to avoid dependency on a libm that could have been
>> separate from libc (bad historical thing). IIRC there was a time when
>> frexp was not used either.
> 
> Does the attached look ok?
> 
> Rich
> <pct_a.diff>


Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.