avformat/wtvdec: Fix signed integer overflow

Happens when length > INT_MAX / 2; use unsigned for the computation,
but restrict the value to INT_MAX, because avio_get_str16le()
accepts an int as buf_len argument. Notice that it can happen
that the string read by avio_get_str16le() is truncated in this case.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2023-09-12 13:46:25 +02:00
parent 197f7e914b
commit 78169f397d
1 changed files with 1 additions and 1 deletions

View File

@ -468,7 +468,7 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty
return;
}
buf_size = FFMAX(2*length, LEN_PRETTY_GUID) + 1;
buf_size = FFMIN(FFMAX(2U * length, LEN_PRETTY_GUID) + 1, INT_MAX);
buf = av_malloc(buf_size);
if (!buf)
return;