Skip to content

Commit

Permalink
common/common.c: vsnprintf_dynamic(): NULL "dst" or its "size" are a …
Browse files Browse the repository at this point in the history
…valid use-case for vsnprintf() [networkupstools#2450]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jun 1, 2024
1 parent a64e7b4 commit 06711d9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 06711d9

Please sign in to comment.