-
Notifications
You must be signed in to change notification settings - Fork 30
Adding heap grooming to avoid non contiguous memory blocks #172
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,8 +2,9 @@ | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| from ctypes import CDLL, c_buffer | ||||||||||||||||||||||||||||||||||
| libc = CDLL('/usr/lib/x86_64-linux-gnu/libc.so.6') | ||||||||||||||||||||||||||||||||||
| prime = [c_buffer(512) for _ in range(10)] | ||||||||||||||||||||||||||||||||||
| buf1 = c_buffer(512) | ||||||||||||||||||||||||||||||||||
| buf2 = c_buffer(512) | ||||||||||||||||||||||||||||||||||
| libc.gets(buf1) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
3
to
8
|
||||||||||||||||||||||||||||||||||
| from ctypes import CDLL, c_buffer | |
| libc = CDLL('/usr/lib/x86_64-linux-gnu/libc.so.6') | |
| prime = [c_buffer(512) for _ in range(10)] | |
| buf1 = c_buffer(512) | |
| buf2 = c_buffer(512) | |
| libc.gets(buf1) | |
| from ctypes import c_buffer | |
| prime = [c_buffer(512) for _ in range(10)] | |
| buf1 = c_buffer(512) | |
| buf2 = c_buffer(512) | |
| # Safely read at most 511 bytes of user input into buf1, leaving room for a null terminator. | |
| user_input = input() | |
| data = user_input.encode('utf-8', errors='ignore')[:511] | |
| buf1.value = data |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open('/flag', 'r').read() leaves the file descriptor open until GC; use a context manager (with open(...) as f:) to ensure the file is closed deterministically.
| print(open('/flag', 'r').read()) | |
| with open('/flag', 'r') as f: | |
| print(f.read()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
primeallocation list is never referenced, so it reads as unused/accidental. If this is intentional heap grooming, consider renaming it to something descriptive (e.g.,heap_groom/groom_allocs) and add a short comment explaining why this allocation count/size is needed to keep the buffers alive and influence layout.