Skip to content

Commit

Permalink
memGuard: Assert that AllowedAccessFlags actually match PROT_* values
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Dec 1, 2024
1 parent be1498d commit be9f10f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions soup/memGuard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ NAMESPACE_SOUP
}
return 0;
}
#else
static_assert(PROT_READ == memGuard::ACC_READ);
static_assert(PROT_WRITE == memGuard::ACC_WRITE);
static_assert(PROT_EXEC == memGuard::ACC_EXEC);
#endif

void* memGuard::alloc(size_t len, int allowed_access)
Expand Down
6 changes: 3 additions & 3 deletions soup/memGuard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ NAMESPACE_SOUP
{
enum AllowedAccessFlags : int
{
ACC_READ = 0x01, // equals PROT_READ on Linux
ACC_WRITE = 0x02, // equals PROT_WRITE on Linux
ACC_EXEC = 0x04, // equals PROT_EXEC on Linux
ACC_READ = 0x01,
ACC_WRITE = 0x02,
ACC_EXEC = 0x04,

ACC_RWX = ACC_READ | ACC_WRITE | ACC_EXEC
};
Expand Down

0 comments on commit be9f10f

Please sign in to comment.