Skip to content

Conversation

@assafnativ
Copy link

File with the hash of ee4b726d2601b084e02f4fb7411a26054fa8a1053f011d3ee9d5a422d93f342c was crashing this parser.

@assafnativ assafnativ force-pushed the nativ/fix_null_deref branch from 16527d1 to a437584 Compare June 3, 2018 13:55
@Idanlu
Copy link

Idanlu commented Oct 4, 2018

+1 for this

// Load sections
const void *sec_data = l->load(m->hdr.shoff,
m->hdr.shentsize * m->hdr.shnum);
if (NULL == sec_data) {
Copy link
Owner

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.

}
for (unsigned i = 0; i < m->hdr.shnum; i++) {
const void *sec = ((const char*)sec_data) + i * m->hdr.shentsize;
if (NULL == sec) {
Copy link
Owner

Choose a reason for hiding this comment

The 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.

// Load sections
const void *sec_data = l->load(m->hdr.shoff,
m->hdr.shentsize * m->hdr.shnum);
if (NULL == sec_data) {
Copy link
Owner

Choose a reason for hiding this comment

The 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: sec_data == NULL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants