From: Tobias Stoeckmann Date: Fri, 16 May 2025 21:50:27 +0000 (+0200) Subject: tar: Clear safe_fprintf stack before usage X-Git-Tag: v3.8.0~15^2~4 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=3f1e45d14673f2a85fb051198c01884a1362a106;p=thirdparty%2Flibarchive.git tar: Clear safe_fprintf stack before usage The stack buffer is never cleared, which can become an issue depending on vsnprintf implementation's behavior if -1 is returned. The code would eventually fall back to stack buffer which might be not nul terminated. Signed-off-by: Tobias Stoeckmann --- diff --git a/tar/util.c b/tar/util.c index 7b9db5ddc..dabb94058 100644 --- a/tar/util.c +++ b/tar/util.c @@ -87,6 +87,7 @@ safe_fprintf(FILE * restrict f, const char * restrict fmt, ...) char try_wc; /* Use a stack-allocated buffer if we can, for speed and safety. */ + memset(fmtbuff_stack, '\0', sizeof(fmtbuff_stack)); fmtbuff_heap = NULL; fmtbuff_length = sizeof(fmtbuff_stack); fmtbuff = fmtbuff_stack;