From: bones_was_here Date: Mon, 15 Jan 2024 00:41:06 +0000 (+1000) Subject: com: detect truncation or error in dpvsnprintf() X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=21fa9010ae6de8792f36cca08cb77aaa95d4b928;p=xonotic%2Fdarkplaces.git com: detect truncation or error in dpvsnprintf() Signed-off-by: bones_was_here --- diff --git a/common.c b/common.c index 8db1f270..d479459c 100644 --- a/common.c +++ b/common.c @@ -1000,6 +1000,11 @@ int dpvsnprintf (char *buffer, size_t buffersize, const char *format, va_list ar if (result < 0 || (size_t)result >= buffersize) { buffer[buffersize - 1] = '\0'; + // we could be inside Con_Printf + if (result < 0) + Sys_Printf("dpvsnprintf: output error, buffer size %zu\n", buffersize); + else + Sys_Printf("dpvsnprintf: truncated to %zu bytes: \"%s\"\n", buffersize - 1, buffer); return -1; }