From e572f9d54f5867b88a49d70d28b0e37a1808ccfa Mon Sep 17 00:00:00 2001 From: Yang Liu Date: Tue, 1 Sep 2026 09:32:23 +0800 Subject: [PATCH] [WRAPPER] Fixed a rare case of madvise wrapping --- src/wrapped/wrappedlibc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 183afac57a..648a12ec86 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -4134,6 +4134,10 @@ EXPORT int my_madvise(x64emu_t* emu, void* addr, size_t length, int advice) return -1; } if(!length) return 0; + if (length > (UINTPTR_MAX - start - (X86_PAGE_SIZE - 1))) { + errno = EINVAL; + return -1; + } uintptr_t end = (start + length + X86_PAGE_SIZE - 1) & ~(X86_PAGE_SIZE - 1); if(advice != MADV_DONTNEED) {