diff options
Diffstat (limited to 'clang/test/Analysis/mmap-writeexec.c')
-rw-r--r-- | clang/test/Analysis/mmap-writeexec.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/test/Analysis/mmap-writeexec.c b/clang/test/Analysis/mmap-writeexec.c index 2d8ea9b6777..2ebc9611034 100644 --- a/clang/test/Analysis/mmap-writeexec.c +++ b/clang/test/Analysis/mmap-writeexec.c @@ -16,6 +16,7 @@ typedef __typeof(sizeof(int)) size_t; void *mmap(void *, size_t, int, int, int, long); +int mprotect(void *, size_t, int); void f1() { @@ -34,3 +35,10 @@ void f2() int prot = PROT_WRITE | PROT_EXEC; (void)callm(NULL, 1024, prot, MAP_PRIVATE | MAP_ANON, -1, 0); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}} } + +void f3() +{ + void *p = mmap(NULL, 1024, PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); // no-warning + int m = mprotect(p, 1024, PROT_WRITE | PROT_EXEC); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}} + (void)m; +} |