-
Notifications
You must be signed in to change notification settings - Fork 98
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
Safer sections iteration #29
base: master
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 |
---|---|---|
|
@@ -103,8 +103,14 @@ elf::elf(const std::shared_ptr<loader> &l) | |
// Load sections | ||
const void *sec_data = l->load(m->hdr.shoff, | ||
m->hdr.shentsize * m->hdr.shnum); | ||
if (NULL == sec_data) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow the coding conventions of the surrounding code, which uses forward comparison: |
||
return; | ||
} | ||
for (unsigned i = 0; i < m->hdr.shnum; i++) { | ||
const void *sec = ((const char*)sec_data) + i * m->hdr.shentsize; | ||
if (NULL == sec) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't make sense for sec to be NULL here, since it's a result from a pointer offset from sec_data. In practice the only way this can happen is if sec_data itself is NULL, but then we shouldn't have even done the pointer arithmetic. |
||
continue; | ||
} | ||
// XXX Circular reference. Maybe this should be | ||
// constructed on the fly? Canonicalizing the header | ||
// isn't super-cheap. | ||
|
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.
loader.load is not allowed to return NULL (it's supposed to throw an exception if there's a problem) and the mmap loader implementation doesn't return NULL, so I'm afraid I don't understand what this change is accomplishing.