From 06711d977b300d50288cb19f917e376567e0d003 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 2 Jun 2024 00:16:01 +0200 Subject: [PATCH] common/common.c: vsnprintf_dynamic(): NULL "dst" or its "size" are a valid use-case for vsnprintf() [#2450] Signed-off-by: Jim Klimov --- common/common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/common.c b/common/common.c index b98de2a126..95a9f5ce63 100644 --- a/common/common.c +++ b/common/common.c @@ -1563,7 +1563,10 @@ int snprintfcat_dynamic(char *dst, size_t size, const char *fmt_dynamic, const c int vsnprintf_dynamic(char *dst, size_t size, const char *fmt_dynamic, const char *fmt_reference, va_list ap) { - if (!dst || size == 0 || validate_formatting_string(fmt_dynamic, fmt_reference, 1) < 0) { + /* NOTE: Not checking for NULL "dst" or its "size", this is a valid + * use-case for vsnprintf() to gauge how long the string would be. + */ + if (validate_formatting_string(fmt_dynamic, fmt_reference, 1) < 0) { return -1; } else { #ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL