Skip to content
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

use-after-free bug in zone.c #66

Closed
ChetanAhuja opened this issue Feb 13, 2014 · 2 comments
Closed

use-after-free bug in zone.c #66

ChetanAhuja opened this issue Feb 13, 2014 · 2 comments

Comments

@ChetanAhuja
Copy link

See my comments in the code below. Very surprising that this hasn't caused widespread crashes (and hasn't been caught before this).

static inline void clear_chunk_list(msgpack_zone_chunk_list* cl, size_t chunk_size)
{
    msgpack_zone_chunk* c = cl->head;         <============ first value of c is the incoming cl->head
    while(true) {
        msgpack_zone_chunk* n = c->next;
        if(n != NULL) {
            free(c);             //                 <===== original cl->head gets free'd here
            c = n;
        } else {
            break;
        }
    }
    cl->head->next = NULL;  //               <=====  same cl->head pointer is being deref'd here.
    cl->free = chunk_size;
    cl->ptr  = ((char*)cl->head) + sizeof(msgpack_zone_chunk);
}
@redboltz
Copy link
Contributor

I believe that this is the same problem as #32 and it have fixed and merged.

@ChetanAhuja
Copy link
Author

Yes it's the same issue. Looks like the pull request for the fix has been merged but hasn't made it into master yet.

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

No branches or pull requests

2 participants