[FFmpeg-devel] [PATCH] [libavformat] Avoid integer overflow on start_time with skip_samples.

Dale Curtis dalecurtis at chromium.org
Fri May 1 01:20:16 EEST 2020


I've sent a follow up patch set implementing saturating operations if
that's something folks are interested in.

- dale

On Thu, Apr 30, 2020 at 2:18 PM Dale Curtis <dalecurtis at chromium.org> wrote:

> That said, instead of aborting the operation, perhaps it'd make more sense
> for library functions to be av_saturated_add(), av_saturated_sub() which
> saturate to INT64_MIN/MAX.
>
> - dale
>
> On Thu, Apr 30, 2020 at 1:26 PM Dale Curtis <dalecurtis at chromium.org>
> wrote:
>
>> Aside: This overflow check is used in quite a few places now. I wonder if
>> it's worth having a function like the following:
>>
>> int64_t av_no_overflow_add(int64_t a, int64_t b) {
>>   return (a > 0 ? b <= INT64_MAX - a : b >= INT64_MIN - a) ? a + b : a;
>> }
>>
>> Better name suggestions welcome... av_maybe_add_ts?
>>
>> On Thu, Apr 30, 2020 at 1:17 PM Dale Curtis <dalecurtis at chromium.org>
>> wrote:
>>
>>> This applies the same workaround used elsewhere in the file for handling
>>> overflow of addition.
>>>
>>> Signed-off-by: Dale Curtis <dalecurtis at chromium.org>
>>> ---
>>>  libavformat/utils.c | 15 +++++++++++----
>>>  1 file changed, 11 insertions(+), 4 deletions(-)
>>>
>>


More information about the ffmpeg-devel mailing list