-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
CVE-2024-28219: Use strncpy to avoid buffer overflow #7928
Conversation
hugovk
commented
Apr 1, 2024
•
edited
Loading
edited
Merging; we don't need to wait for valgrind or AppVeyor to finish testing the latest commit which was docs only. |
I'll update CHANGES.rst with this when bumping the version. |
Or you already did, no problem :) |
strncpy(self->mode_in, mode_in, 8); | ||
strncpy(self->mode_out, mode_out, 8); |
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.
strncpy
doesn’t null-terminate oversized entries.
strncpy(self->mode_in, mode_in, 8); | |
strncpy(self->mode_out, mode_out, 8); | |
strncpy(self->mode_in, mode_in, 8); | |
self->mode_in[7] = '\0'; | |
strncpy(self->mode_out, mode_out, 8); | |
self->mode_out[7] = '\0'; |
But are these even used? The Python ImageCmsTransform
wrapper has inputMode
and outputMode
attributes already, and they work normally. Is there a need to preserve a slightly different .transform.inputMode
?
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.
Probably not, see #7931 for a suggestion to remove them.
Is this exploitable when all you do is opening user-provided images and converting them? Or only when you explicitly used the |
Something outside of Pillow would have to use ImageCms, yes. |
It looks like Line 1079 in 955c5da
|
If you look a few lines earlier Lines 1070 to 1079 in 955c5da
you will see that one of the modes has to be "LAB", and the other has to be one of "RGB", "RGBA" or "RGBX", none of which is more than 8 characters. So it isn't exploitable from |