[FFmpeg-devel] [PATCH]lavf/mov: Do not blindly allocate stts entries

Derek Buitenhuis derek.buitenhuis at gmail.com
Fri Dec 29 22:35:51 EET 2017


On 12/29/2017 8:25 PM, Carl Eugen Hoyos wrote:
> 2017-12-29 20:47 GMT+01:00 Derek Buitenhuis <derek.buitenhuis at gmail.com>:
>> On 12/29/2017 1:10 AM, Carl Eugen Hoyos wrote:
>>> New patch attached, only tested with fate.
>>
>>> +    if (INT_MAX / sizeof(*sc->stts_data) <= entries)
> 
> This is an arbitrary limit...

Yeah, true. I should have pointed that out too.

> 
>>>          return AVERROR(ENOMEM);
>>
>> Should probably be something thing AVERROR(EINVAL), I think.
> 
> ... and it is therefore - imo - not correct to return EINVAL.

ENOMEM is arguably even more incorrect, though.

> 
>>> +    sc->stts_count = FFMIN(1024 * 1024, entries);
> 
> This is not a limit and therefore not an arbitrary limit.

... what? It is a limit on the size of stts_count. A arbitrary (1mb) one.

In any case, I misunderstood this part, and it is OK. Sorry about that - disregard
my complaint.

FFMIN(sc->stts_count * 2, entries) could in theory end up using more memory
for legitimate large files though, due to exponential buffer growth. Is that
something worth caring about?

Other than that, seems OK. Sorry for the noise.

- Derek


More information about the ffmpeg-devel mailing list