fix oob bug in tests file2 module (#28586)

This commit is contained in:
XiaoYang Chen
2026-09-28 10:09:20 -06:00
committed by GitHub
parent c865dc9fde
commit 46a77d8ad1
+7
View File
@@ -55,6 +55,7 @@
#define FLAG_LSEEK 2
#define LOG_PATH PX4_STORAGEDIR
#define MAX_WRITE_CHUNK 4096U
/*
return a predictable value for any file offset to allow detection of corruption
@@ -198,6 +199,12 @@ int test_file2(int argc, char *argv[])
case 'c':
write_chunk = strtoul(myoptarg, NULL, 0);
if (write_chunk > MAX_WRITE_CHUNK || write_chunk <= 0) {
fprintf(stderr, "invalid IO chunk size (expected 1-%u)\n", MAX_WRITE_CHUNK);
return -EINVAL;
}
break;
case 'h':