From 1af28aebd7385104d31f8a7e5e307600b97cad5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Thu, 11 Jun 2026 17:33:01 +0200 Subject: [PATCH] musl, wasi-libc: apply Rich Felker's floatscan.c patch fixing strtod() rounding https://www.openwall.com/lists/musl/2026/05/21/3 --- lib/libc/musl/src/internal/floatscan.c | 2 +- lib/libc/wasi/libc-top-half/musl/src/internal/floatscan.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/musl/src/internal/floatscan.c b/lib/libc/musl/src/internal/floatscan.c index 8c0828fcb39e6e0e742309913eef1aa955e582e5..b15366b685e9757d56b3c41d5caf7a69c4682d35 100644 --- a/lib/libc/musl/src/internal/floatscan.c +++ b/lib/libc/musl/src/internal/floatscan.c @@ -347,7 +347,7 @@ static long double hexfloat(FILE *f, int bits, int emin, int sign, int pok) else d = c-'0'; if (dc<8) { x = x*16 + d; - } else if (dc < LDBL_MANT_DIG/4+1) { + } else if (dc < (LDBL_MANT_DIG+3)/4+1) { y += d*(scale/=16); } else if (d && !gottail) { y += 0.5*scale; diff --git a/lib/libc/wasi/libc-top-half/musl/src/internal/floatscan.c b/lib/libc/wasi/libc-top-half/musl/src/internal/floatscan.c index ec50fe0765046a04a8757bb7114f8ed530a6ed09..4cc6059f438e4368da315a13f12988f0ea1ec3f2 100644 --- a/lib/libc/wasi/libc-top-half/musl/src/internal/floatscan.c +++ b/lib/libc/wasi/libc-top-half/musl/src/internal/floatscan.c @@ -388,7 +388,7 @@ static long double hexfloat(FILE *f, int bits, int emin, int sign, int pok) else d = c-'0'; if (dc<8) { x = x*16 + d; - } else if (dc < LDBL_MANT_DIG/4+1) { + } else if (dc < (LDBL_MANT_DIG+3)/4+1) { y += d*(scale/=16); } else if (d && !gottail) { y += 0.5*scale; -- 2.54.0