-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
check if ":" exists before index(':') #1159
Conversation
pwnlib/util/proc.py
Outdated
@@ -245,6 +245,8 @@ def status(pid): | |||
try: | |||
with open('/proc/%d/status' % pid) as fd: | |||
for line in fd: | |||
if -1 == line.find(':'): |
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.
Maybe this looks better?
if ':' not in line:
continue
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.
Yeah, this would probably be better. Thanks!
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.
Thanks!
pwnlib/util/proc.py
Outdated
@@ -245,6 +245,8 @@ def status(pid): | |||
try: | |||
with open('/proc/%d/status' % pid) as fd: | |||
for line in fd: | |||
if -1 == line.find(':'): |
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.
Yeah, this would probably be better. Thanks!
When I use
gdb.attach(p)
, I get an error:ValueError: substring not found
I debug it and found that the file /proc/%d/status may have blank line. But util/proc.py doesn't solve it very well. If status file has blank line, then it will raise an error.
So I add some code to detect if ":" exists. If find ":" failed, it will continue.
Sorry for my bad english ...