[PATCH v5 0/2] lib/vsprintf: Fixes size check

From: Masami Hiramatsu (Google)

Date: Wed Mar 25 2026 - 09:57:36 EST


Hi,

Here is the 5th version of patches to fix vsnprintf().

- Fix to limit the size of width and precision.
- Warn if the return size is over INT_MAX.

Previous version is here;

https://lore.kernel.org/all/177440550682.147866.1854734911195480940.stgit@devnote2/

In this version, negative precision is treated as zero to match the
previous behavior and check the field/precision passed as string
literals too[1/2]. Also, update bstr_printf() not to return negative
value[2/2].

Thank you,

---

Masami Hiramatsu (Google) (2):
lib/vsprintf: Fix to check field_width and precision
lib/vsprintf: Limit the returning size to INT_MAX


lib/vsprintf.c | 54 ++++++++++++++++++++++++++++++------------------------
1 file changed, 30 insertions(+), 24 deletions(-)

--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>