Diff between 25c23ffca7e6c1aba67ae685ba3fc9060efacd82 and e18ce6c959a1135b3487ce0a63bea3e319b89a43
Changed Files
| File | Additions | Deletions | Status |
| tools/test-runner.c | +9 | -1 | modified |
Full Patch
diff --git a/tools/test-runner.c b/tools/test-runner.c
index 1d77033..7c9386d 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -261,7 +261,15 @@ static void start_qemu(void)
for (i = 1; i < test_argc; i++) {
int len = sizeof(testargs) - pos;
- pos += snprintf(testargs + pos, len, " %s", test_argv[i]);
+ int n = snprintf(testargs + pos, len, " %s", test_argv[i]);
+
+ if (n < 0 || n >= len) {
+ fprintf(stderr, "Buffer overflow detected in "
+ "testargs\n");
+ exit(EXIT_FAILURE);
+ }
+
+ pos += n;
}
snprintf(cmdline, sizeof(cmdline),