mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-12-07 10:28:30 +00:00
Fixed mprotect() being called with invalid length values (bug 3642, r=ds).
This commit is contained in:
parent
b2b6c22b30
commit
ee50d4adfc
@ -26,6 +26,7 @@
|
|||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
# include <setjmp.h>
|
# include <setjmp.h>
|
||||||
|
# include <stdint.h>
|
||||||
// http://www.die.net/doc/linux/man/man2/mprotect.2.html
|
// http://www.die.net/doc/linux/man/man2/mprotect.2.html
|
||||||
# include <limits.h>
|
# include <limits.h>
|
||||||
# ifndef PAGESIZE
|
# ifndef PAGESIZE
|
||||||
@ -37,8 +38,8 @@
|
|||||||
|
|
||||||
// We need to align addr down to pagesize on linux
|
// We need to align addr down to pagesize on linux
|
||||||
// We assume PAGESIZE is a power of two
|
// We assume PAGESIZE is a power of two
|
||||||
# define SH_LALIGN(x) (void*)((intptr_t)(x) & ~(PAGESIZE-1))
|
# define SH_LALIGN(x) (void*)((uintptr_t)(x) & ~(PAGESIZE-1))
|
||||||
# define SH_LALDIF(x) ((intptr_t)(x) & (PAGESIZE-1))
|
# define SH_LALDIF(x) ((uintptr_t)(x) & (PAGESIZE-1))
|
||||||
# else
|
# else
|
||||||
# error Unsupported OS/Compiler
|
# error Unsupported OS/Compiler
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
# include <setjmp.h>
|
# include <setjmp.h>
|
||||||
|
# include <stdint.h>
|
||||||
// http://www.die.net/doc/linux/man/man2/mprotect.2.html
|
// http://www.die.net/doc/linux/man/man2/mprotect.2.html
|
||||||
# include <limits.h>
|
# include <limits.h>
|
||||||
# ifndef PAGESIZE
|
# ifndef PAGESIZE
|
||||||
@ -37,8 +38,8 @@
|
|||||||
|
|
||||||
// We need to align addr down to pagesize on linux
|
// We need to align addr down to pagesize on linux
|
||||||
// We assume PAGESIZE is a power of two
|
// We assume PAGESIZE is a power of two
|
||||||
# define SH_LALIGN(x) (void*)((intptr_t)(x) & ~(PAGESIZE-1))
|
# define SH_LALIGN(x) (void*)((uintptr_t)(x) & ~(PAGESIZE-1))
|
||||||
# define SH_LALDIF(x) ((intptr_t)(x) % PAGESIZE)
|
# define SH_LALDIF(x) ((uintptr_t)(x) % PAGESIZE)
|
||||||
# else
|
# else
|
||||||
# error Unsupported OS/Compiler
|
# error Unsupported OS/Compiler
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user