picture: check each plane dimension doesn't overflow
Merge request reports
Activity
changed milestone to %4.0
added Component::Core Component::Decoders labels
added MRStatus::Acceptable label
181 181 182 182 /* A plane cannot be over-sampled. This could lead to overflow. */ 183 183 assert(h->den >= h->num); 184 assert(w->den >= w->num); 184 assert(2 * w->den >= w->num); I don't understand what would overflow. The code is just setting the planes pitch/lines according to the picture format.
The buffer allocation is done later in
picture_NewFromFormat()
and it's adding the full pitch/lines to compute the size of the buffers. There are checks that the sum cannot be bigger than asize_t
.As for the rest of the code, it doesn't care about the dimensions differences between each planes. Each plane is used independently.
If there's an actual limitation with NV24/NV42 we should not allow to map it to VLC pictures at all. But I don't see it.
There's a potential integer overflow for at least
i_pitch
and probablyi_visible_pitch
becausewidth
is checked as lower thanINT_MAX
.If the numerator is smaller than the denominator, multiplying by
w->num/w->den
is bound to be lower than 1 which isn't true anymore with this assert.Edited by Denis CharmetIIUC, the point is that you should probably make sure that
(width <= INT_MAX/(2 * p_dsc->pixel_size))
Assuming obviously that
pixel_size
can't be null.Edited by Denis Charmetchanged this line in version 2 of the diff
I added a multiplication check on each plane so no plane dimension can ever be bigger than
INT_MAX
.w->num/w->den
We don't do that, first we multiply by
w->num
and then the result is divided byw->den
. So 2 by 1/2 ends up being 1, not 0. The operation split is even more visible now withckd_mul()
.Isn't that protected by the following check?
#define PICTURE_SW_SIZE_MAX (UINT32_C(1) << 28) /* 256MB: 8K * 8K * 4*/ [...] if (unlikely(pic_size >= PICTURE_SW_SIZE_MAX)) goto error;
Or am I missing/misunderstanding something?
Edited by Denis CharmetThe current limits are 8192 pixels in each dimension, 8 bytes per pixel and 1:1 sampling. Multiplying it all together, we get up to 2 to the power 29. We refused to double the dimension to avoid getting to 31, which would be signed overflow. AFAICT, the same limit affects increasing the sampling.
added MRStatus::InReview label and removed MRStatus::Acceptable label
added MRStatus::Stale label and removed MRStatus::InReview label