diff --git a/src/lib/syscall.c b/src/lib/syscall.c index 0edd460..d520c0a 100644 --- a/src/lib/syscall.c +++ b/src/lib/syscall.c @@ -17,6 +17,8 @@ #include #include +#include +#include #include @@ -112,6 +114,19 @@ LIBC_SYSCALL_DECL LIBC_SYSCALL_RET_TYPE ret; va_list args; +#if defined(SYS_mmap) || defined(SYS_mmap2) + if (NULL == tsocks_libc_syscall) { + switch (__number) { + case SYS_mmap: +#ifdef SYS_mmap2 + case SYS_mmap2: +#endif + fprintf(stderr, "Panic! mmap has been called before we had our hands on the real syscall()\n"); + exit(EXIT_FAILURE); + break; + } + } +#endif /* Find symbol if not already set. Exit if not found. */ tsocks_libc_syscall = tsocks_find_libc_symbol(LIBC_SYSCALL_NAME_STR, TSOCKS_SYM_EXIT_NOT_FOUND);