int vsnprintf(char *buf, size_t size, const char *fmt_str, va_list args)
{
char *str, *end;
+ size_t ret_size;
struct printf_spec spec = {0};
struct fmt fmt = {
.str = fmt_str,
}
/* the trailing null byte doesn't count towards the total */
- return str-buf;
+ ret_size = str - buf;
+ /* Make sure the return value is within the positive integer range */
+ if (WARN_ON_ONCE(ret_size > INT_MAX))
+ ret_size = INT_MAX;
+ return ret_size;
}
EXPORT_SYMBOL(vsnprintf);
struct printf_spec spec = {0};
char *str, *end;
const char *args = (const char *)bin_buf;
+ size_t ret_size;
if (WARN_ON_ONCE(size > INT_MAX))
return 0;
#undef get_arg
/* the trailing null byte doesn't count towards the total */
- return str - buf;
+ ret_size = str - buf;
+
+ /* Make sure the return value is within the positive integer range */
+ if (WARN_ON_ONCE(ret_size > INT_MAX))
+ ret_size = INT_MAX;
+ return ret_size;
}
EXPORT_SYMBOL_GPL(bstr_printf);