[PATCH] vsnprintf: POSIX compliance for return value length

From: Jake
Date: Wed Jul 02 2025 - 08:25:05 EST


Greetings.

The current implementation of vsnprintf() returns the number of characters
actually written to the buffer, which does not comply with the POSIX
specification. POSIX requires vsnprintf() to return the number of characters
it *would* have written, even if that exceeds the buffer size, so callers can
detect truncation.

This patch adds a `total_len` counter, updates all output paths to increment
it, and returns `total_len` instead of the truncated output count.

Signed-off-by: Jake <jakecontactxyz@xxxxxxxxx>

Attachment: vsnprintf_patch.zip
Description: Zip archive