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.