From c167bbbc7e0e9510325dfbc1eee751fa7294e82a Mon Sep 17 00:00:00 2001 From: AFWEF_147 Date: Mon, 30 Mar 2026 12:36:17 +0000 Subject: fix(tmpfs): harden path component bounds and validation --- examples/utest/testcases/tmpfs/tmpfs.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'examples/utest') diff --git a/examples/utest/testcases/tmpfs/tmpfs.c b/examples/utest/testcases/tmpfs/tmpfs.c index 6eaa973907..647944a714 100644 --- a/examples/utest/testcases/tmpfs/tmpfs.c +++ b/examples/utest/testcases/tmpfs/tmpfs.c @@ -9,6 +9,9 @@ */ #include #include +#include +#include +#include #include #include "utest.h" #include "utest_assert.h" @@ -52,6 +55,20 @@ void run_copy() uassert_true(1); } + + +static void run_long_name_reject(void) +{ + static const char long_name[] = + "/tmp/abcdefghijklmnopqrstuvwxyz1234567890"; + int fd; + + errno = 0; + fd = open(long_name, O_CREAT | O_RDWR, 0); + uassert_int_equal(fd, -1); + uassert_int_equal(errno, -ENAMETOOLONG); +} + static rt_err_t utest_tc_init(void) { return RT_EOK; @@ -64,5 +81,6 @@ static rt_err_t utest_tc_cleanup(void) static void testcase(void) { UTEST_UNIT_RUN(run_copy); + UTEST_UNIT_RUN(run_long_name_reject); } UTEST_TC_EXPORT(testcase, "testcase.tfs.tmpfs", utest_tc_init, utest_tc_cleanup, 10); -- cgit v1.3.1