-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
Fix read past the end of a buffer in pool.c
.
#2139
Conversation
This change fixes `ponyint_pool_realloc_size`, which was reading past the end of the old buffer, which in some circumstances triggered a page fault.
src/libponyrt/mem/pool.c
Outdated
@@ -971,7 +971,7 @@ void* ponyint_pool_realloc_size(size_t old_size, size_t new_size, void* p) | |||
new_p = pool_alloc_size(new_adj_size); | |||
} | |||
|
|||
memcpy(new_p, p, new_size); | |||
memcpy(new_p, p, old_size); |
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.
Good catch!
But is it guaranteed that old_size < new_size
here?
If not, wouldn't we want to take min(old_size, new_size)
as the copy length?
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.
D'oh, of course.
I'm going to go out on a limb and say we should do a 0.17.1 for this. Thoughts? |
So far it looks like this function is only used in the compiler, not in the runtime. Is that correct, @kulibali and @Praetonus? If that's correct, I wouldn't necessarily consider this to be a release-triggering fix. |
It looks like it is only used in |
ok, no release then! good. i did want to go through that again today. |
Is this changelog-worthy? |
This change fixes
ponyint_pool_realloc_size
, which was reading past the end of the old buffer, which in some circumstances triggered a page fault.