* [musl] [PATCH] printf core: fix gratuitous integer formatting buffer size
@ 2023-06-13 0:10 Rich Felker
0 siblings, 0 replies; only message in thread
From: Rich Felker @ 2023-06-13 0:10 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 118 bytes --]
Heads up: if there are no objections, I'm planning to commit this so
that the C23 patches don't have to deal with it.
[-- Attachment #2: 0001-printf-core-fix-gratuitous-integer-formatting-buffer.patch --]
[-- Type: text/plain, Size: 1257 bytes --]
From 40834f6c1e30cc25c608678c372db498a3d9dbc3 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Mon, 12 Jun 2023 20:04:22 -0400
Subject: [PATCH] printf core: fix gratuitous integer formatting buffer size
the extra terms 3 and LDBL_MANT_DIG/4 are remnants of a proto-musl
implementation of printf where the sign/prefix and floating point
conversions were performed naively into this buffer. having them there
obscures the actual intended buffer size (sufficient to hold between 2
and 3 octal digits per byte, rounded up to 3 for simplicity) and
interferes with upcoming work to add C2x binary formats which would
otherwise be stuck having to explain a similar fix to buffer size as
part of an unrelated change.
---
src/stdio/vfprintf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
index c551ccf0..33019ff1 100644
--- a/src/stdio/vfprintf.c
+++ b/src/stdio/vfprintf.c
@@ -437,7 +437,7 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
unsigned st, ps;
int cnt=0, l=0;
size_t i;
- char buf[sizeof(uintmax_t)*3+3+LDBL_MANT_DIG/4];
+ char buf[sizeof(uintmax_t)*3];
const char *prefix;
int t, pl;
wchar_t wc[2], *ws;
--
2.21.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-13 0:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 0:10 [musl] [PATCH] printf core: fix gratuitous integer formatting buffer size Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).