From 46a77d8ad15e7929ef261c41083dffd1bbfa9f85 Mon Sep 17 00:00:00 2001 From: XiaoYang Chen <34237762+godesady@users.noreply.github.com> Date: Tue, 29 Sep 2026 00:09:20 +0800 Subject: [PATCH] fix oob bug in tests file2 module (#28586) --- src/systemcmds/tests/test_file2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/systemcmds/tests/test_file2.c b/src/systemcmds/tests/test_file2.c index 606f39abf30..f1efdc73beb 100644 --- a/src/systemcmds/tests/test_file2.c +++ b/src/systemcmds/tests/test_file2.c @@ -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':