From: Glenn Washburn Date: Fri, 18 Aug 2023 17:15:27 +0000 (-0500) Subject: kern/misc: Make grub_vsnprintf() C99/POSIX conformant X-Git-Tag: grub-2.12~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14c95e57fddb6c826bee7755232de62efc8eb45b;p=thirdparty%2Fgrub.git kern/misc: Make grub_vsnprintf() C99/POSIX conformant To comply with C99 and POSIX standards, snprintf() should return the number of bytes that would be written to the string (excluding the terminating NUL byte) if the buffer size was big enough. Before this change, the return value was the minimum of the standard return and the length of the buffer. Rarely is the return value of grub_snprintf() or grub_vsnprintf() used with current code, and the few places where it is used do not need to be changed. Signed-off-by: Glenn Washburn Reviewed-by: Daniel Kiper --- diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 2890aad49..b57249acb 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -1201,7 +1201,7 @@ grub_vsnprintf (char *str, grub_size_t n, const char *fmt, va_list ap) free_printf_args (&args); - return ret < n ? ret : n; + return ret; } int