Commit 11251b5f authored by Ramon Nou's avatar Ramon Nou
Browse files

fix hook_statx nullpointer log

parent dfb5bcc0
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -154,6 +154,15 @@ int
hook_statx(int dirfd, const char* path, int flags, unsigned int mask,
           struct ::statx* buf) {
    bool follow = (flags & AT_SYMLINK_NOFOLLOW) == 0;

    // When AT_EMPTY_PATH is set, path may legally be nullptr or "".
    // In that case it is an fstat-style call on an fd; forward directly to
    // the kernel to avoid a null-pointer dereference in fmt::format.
    if(path == nullptr || (flags & AT_EMPTY_PATH) != 0) {
        return gsl::narrow_cast<int>(syscall_no_intercept_wrapper(
                SYS_statx, dirfd, path, flags, mask, buf));
    }

    LOG(DEBUG,
        "{}() called with dirfd: '{}', path: \"{}\", flags: '{}', mask: '{}', buf: '{}'",
        __func__, dirfd, path, flags, mask, fmt::ptr(buf));