Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds test for memory max_exec_size #1524

Merged
merged 1 commit into from
Sep 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/native/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,28 @@ def test_access_symbolic_w(self):
mem[sym] = "\x40"
mem[sym] = val

def test_max_exec_size(self):
mem = Memory32()
# start with no maps
self.assertEqual(len(mem.mappings()), 0)

# alloc/map a byte
notExecMap = mem.mmap(0x1000, 0x1000, "rw")
isExecMap = mem.mmap(0x2000, 0x1000, "x")
anotherExecMap = mem.mmap(0x3000, 0x1000, "rwx")
# Okay 2 maps
self.assertEqual(len(mem.mappings()), 3)

# 0 size when not executable at all
self.assertEqual(mem.max_exec_size(notExecMap - 1, 16), 0)
self.assertEqual(mem.max_exec_size(notExecMap, 16), 0)
# maximum size when executable
self.assertEqual(mem.max_exec_size(isExecMap, 16), 16)
# maximum size when executable across maps
self.assertEqual(mem.max_exec_size(isExecMap + 0x1000 - 12, 16), 16)
# restricted size when executable until boundary
self.assertEqual(mem.max_exec_size(anotherExecMap + 0x1000 - 12, 16), 12)

def test_access(self):
mem = Memory32()

Expand Down