From be9f10f5a7f0b13d8ebb0546380e4cfbc0e9eb4c Mon Sep 17 00:00:00 2001 From: Sainan Date: Sun, 1 Dec 2024 15:47:00 +0100 Subject: [PATCH] memGuard: Assert that AllowedAccessFlags actually match PROT_* values --- soup/memGuard.cpp | 4 ++++ soup/memGuard.hpp | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/soup/memGuard.cpp b/soup/memGuard.cpp index 9ecd5a03..9c53e246 100644 --- a/soup/memGuard.cpp +++ b/soup/memGuard.cpp @@ -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) diff --git a/soup/memGuard.hpp b/soup/memGuard.hpp index d1fde23d..1d8c574b 100644 --- a/soup/memGuard.hpp +++ b/soup/memGuard.hpp @@ -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 };