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

mp_buf_append and sanitizing realloc #66

Open
gottfriedleibniz opened this issue Oct 6, 2021 · 0 comments
Open

mp_buf_append and sanitizing realloc #66

gottfriedleibniz opened this issue Oct 6, 2021 · 0 comments

Comments

@gottfriedleibniz
Copy link

gottfriedleibniz commented Oct 6, 2021

I noticed mp_buf_append and mp_buf_new are not sanitizing the result to mp_realloc.

The Lua documentation states that when the pointer is non-null is must behave like realloc (and in the default case it is: return realloc(ptr, nsize)). In turn, when realloc fails the original block is left untouched and NULL is returned, which paths into a memcpy (and likely segmenta.... fau.. or something else entirely dependent on buf->len).

While a minor issue, a bit of defensive programming here would not hurt.

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

1 participant