From b604a007d64cc28fdaeee3ef7c1ecc9f725fb209 Mon Sep 17 00:00:00 2001 From: Marco Edoardo Santimaria Date: Sat, 6 Dec 2025 11:55:34 +0100 Subject: [PATCH] Fixed bug on stat handler --- capio/posix/handlers/stat.hpp | 9 +++++++++ capio/posix/handlers/statx.hpp | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/capio/posix/handlers/stat.hpp b/capio/posix/handlers/stat.hpp index a205a50aa..7685098d6 100644 --- a/capio/posix/handlers/stat.hpp +++ b/capio/posix/handlers/stat.hpp @@ -150,6 +150,9 @@ int fstat_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long ar int fstatat_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long *result) { + if (arg1 == NULL || arg2 == NULL) { + return CAPIO_POSIX_SYSCALL_SKIP; + } auto dirfd = static_cast(arg0); const std::string_view pathname(reinterpret_cast(arg1)); auto *statbuf = reinterpret_cast(arg2); @@ -160,6 +163,9 @@ int fstatat_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long } int lstat_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long *result) { + if (arg0 == NULL) { + return CAPIO_POSIX_SYSCALL_SKIP; + } const std::string_view pathname(reinterpret_cast(arg0)); auto *buf = reinterpret_cast(arg1); long tid = syscall_no_intercept(SYS_gettid); @@ -168,6 +174,9 @@ int lstat_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long ar } int stat_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long *result) { + if (arg0 == NULL) { + return CAPIO_POSIX_SYSCALL_SKIP; + } const std::string_view pathname(reinterpret_cast(arg0)); auto *buf = reinterpret_cast(arg1); long tid = syscall_no_intercept(SYS_gettid); diff --git a/capio/posix/handlers/statx.hpp b/capio/posix/handlers/statx.hpp index bfe984d8a..2045a968c 100644 --- a/capio/posix/handlers/statx.hpp +++ b/capio/posix/handlers/statx.hpp @@ -102,6 +102,10 @@ inline int capio_statx(int dirfd, const std::string_view &pathname, int flags, i } int statx_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long *result) { + if (arg1 == NULL) { + return CAPIO_POSIX_SYSCALL_SKIP; + } + auto dirfd = static_cast(arg0); const std::string_view pathname(reinterpret_cast(arg1)); auto flags = static_cast(arg2);