[FFmpeg-devel] [PATCH 01/25] avformat/matroskaenc: Fix potential overflow

James Almer jamrial at gmail.com
Mon Jan 17 00:51:50 EET 2022



On 1/16/2022 7:49 PM, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>   libavformat/matroskaenc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 41b2df7dbf..1dde12a7d9 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -286,7 +286,7 @@ static void put_ebml_uint(AVIOContext *pb, uint32_t elementid, uint64_t val)
>   static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val)
>   {
>       int i, bytes = 1;
> -    uint64_t tmp = 2*(val < 0 ? val^-1 : val);
> +    uint64_t tmp = 2 * (uint64_t)(val < 0 ? val^-1 : val);

nit: 2ULL is shorter.

>   
>       while (tmp >>= 8)
>           bytes++;


More information about the ffmpeg-devel mailing list