-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(commands/hexdump): Add configurable size limit #2803
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #2803 +/- ##
========================================
+ Coverage 5.44% 9.93% +4.49%
========================================
Files 225 223 -2
Lines 25493 25424 -69
Branches 3863 3855 -8
========================================
+ Hits 1388 2527 +1139
+ Misses 23914 22460 -1454
- Partials 191 437 +246 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pwndbg/commands/hexdump.py
Outdated
| help_docstring="""Set the maximum size in megabytes (MB) that the `hexdump` command will attempt to read at once. | ||
| Prevents GDB crashes due to excessive memory allocation requests. | ||
| Set to 0 for unlimited (use with caution).""", | ||
| param_class=3, |
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.
What is param_class?
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 value 3 corresponds to PARAM_ZUINTEGER, which means "Unsigned integer, allows 0". This is the correct type for hexdump-limit-mb because the limit should be a non-negative number of megabytes, and we specifically want to allow 0 as a valid value to signify "unlimited".
I initially encountered a mypy type-checking error when trying to import and use the PARAM_ZUINTEGER constant directly (it was incorrectly inferred as the wrong type). As a temporary workaround during debugging, I used the literal value 3. I mistakenly forgot to revert this to the proper method, which involves importing the constant correctly, before submitting the PR.
ad41236 to
e97862e
Compare
|
Updated the code to use the correct import from pwndbg.lib.config import PARAM_ZUINTEGER and the PARAM_ZUINTEGER constant for param_class. |
|
Thanks! |
This PR prevents GDB from crashing due to OOM errors when
hexdumpis called with an excessively large count.It introduces a check before attempting the memory read, comparing the requested count against a new configurable limit. If the count exceeds the limit, a
ValueErroris raised with an informative message guiding the user on how to adjust the limit.hexdump-limit-mbFixes #2608