Skip to content

Commit

Permalink
Fixed fcntl
Browse files Browse the repository at this point in the history
  • Loading branch information
drowaudio committed Jun 3, 2024
1 parent 6e1e424 commit 48b2b5d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/rtcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,21 @@ INTERCEPTOR(int, fcntl, int filedes, int cmd, ...)

va_list args;
va_start(args, cmd);
void *arg = va_arg(args, void*);

// From RTsan:
// Following precedent here. The linux source (fcntl.c, do_fcntl) accepts the
// final argument in a variable that will hold the largest of the possible
// argument types (pointers and ints are typical in fcntl) It is then assumed
// that the implementation of fcntl will cast it properly depending on cmd.
//
// This is also similar to what is done in
// sanitizer_common/sanitizer_common_syscalls.inc
const unsigned long arg = va_arg(args, unsigned long);
int result = REAL(fcntl)(filedes, cmd, arg);

va_end(args);

return fcntl(filedes, cmd, arg);
return result;
}

//==============================================================================
Expand Down

0 comments on commit 48b2b5d

Please sign in to comment.