summaryrefslogtreecommitdiff
path: root/include/elf.h
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2025-07-01 21:30:18 -0400
committerRich Felker <dalias@aerifal.cx>2025-07-01 21:30:18 -0400
commitf96e47a26102d537c29435f0abf9ec94676a030e (patch)
tree0223c00c463c4258c5ec73fc31e9d480f2980315 /include/elf.h
parentcaae5a8b272861607c25f8ed86087bae960a07f0 (diff)
downloadmusl-f96e47a26102d537c29435f0abf9ec94676a030e.tar.gz
printf: fix regression in large double formatting on ld128 archs
commit 572a2e2eb91f00f2f25d301cfb50f435e7ae16b3 adjusted the buffer for decimal conversion to be a VLA that only uses the full size needed for long double when the argument type was long double. however, it failed to update a later expression for the positioning within the buffer, which still used a fixed offset of LDBL_MANT_DIG. this caused doubles with a large positive exponent to overflow below the start of the array, producing wrong output and potentially runaway wrong execution. this bug has not been present in any release, and has not been analyzed in depth for security considerations. it turns out the original buffer offset expression involving LDBL_MANT_DIG was incorrect as well, and only worked because the space reserved for expanding the exponent is roughly 3 times the size it needs to be when the exponent is positive, leaving plenty of extra space to compensate for the error. the actual offset should be in base-1000000000 slot units, not bits, and numerically equal to the number of slots that were previously allocated for mantissa expansion. in order to ensure consistency and make the code more comprehensible, commented subexpressions are replaced by intermediate named variables, and the newly introduced max_mant_slots is used for both the allocation and the buffer offset adjustment. the included +1 term accounts for a trailing zero slot that's always emitted.
Diffstat (limited to 'include/elf.h')
0 files changed, 0 insertions, 0 deletions