Fix buffer overflow in test_printf (fixes #1)

This commit is contained in:
2025-12-07 15:41:15 +01:00
parent ee4883774e
commit c12c4c7bbf
+4
View File
@@ -31,6 +31,10 @@ void test_printf(char *fmt, ...)
sizeof(test_output_buffer) - test_output_buffer_used, sizeof(test_output_buffer) - test_output_buffer_used,
fmt, args); fmt, args);
va_end(args); va_end(args);
assert(len > -1);
if (len > (int) sizeof(test_output_buffer) - test_output_buffer_used)
len = sizeof(test_output_buffer) - test_output_buffer_used;
test_output_buffer_used += len; test_output_buffer_used += len;
} }