This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit f540d54d0301bf54dd6108e211ab971d761a5f8d
Author: pengyinjie <[email protected]>
AuthorDate: Wed Dec 17 19:17:40 2025 +0800

    sched/assert: Fix stack_dump boundary check to prevent buffer overflow
    
    DUMP_PTR() only checked that the read of p[x] starts below stack_top,
    so the read could still end past stack_top when less than a pointer is
    left between &p[x] and stack_top.  Check &p[x + 1] <= stack_top
    instead, so the whole read stays within the stack.
    
    Signed-off-by: pengyinjie <[email protected]>
---
 sched/misc/assert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sched/misc/assert.c b/sched/misc/assert.c
index 4e8490549bc..b1e9a7cd994 100644
--- a/sched/misc/assert.c
+++ b/sched/misc/assert.c
@@ -96,7 +96,7 @@
 #  undef CONFIG_ARCH_USBDUMP
 #endif
 
-#define DUMP_PTR(p, x) ((uintptr_t)(&(p)[(x)]) < stack_top ? (p)[(x)] : 0)
+#define DUMP_PTR(p, x) ((uintptr_t)(&(p)[(x) + 1]) <= stack_top ? (p)[(x)] : 0)
 #define DUMP_STRIDE    (sizeof(FAR void *) * 8)
 
 #if UINTPTR_MAX <= UINT32_MAX

Reply via email to