demux_mkv: minor improvement to overflow check

CC: @mpv-player/stable
This commit is contained in:
wm4 2014-07-02 00:14:18 +02:00
parent 9a210ca2d5
commit bb131f4c66
1 changed files with 3 additions and 2 deletions

View File

@ -271,7 +271,8 @@ static bstr demux_mkv_decode(struct mp_log *log, mkv_track_t *track,
} else if (enc->comp_algo == 2) { } else if (enc->comp_algo == 2) {
/* lzo encoded track */ /* lzo encoded track */
int out_avail; int out_avail;
if (size > INT_MAX / 3 + AV_LZO_OUTPUT_PADDING) int maxlen = INT_MAX - AV_LZO_OUTPUT_PADDING;
if (size >= maxlen / 3)
goto error; goto error;
int dstlen = size * 3; int dstlen = size * 3;
@ -291,7 +292,7 @@ static bstr demux_mkv_decode(struct mp_log *log, mkv_track_t *track,
goto error; goto error;
} }
mp_dbg(log, "lzo decompression buffer too small.\n"); mp_dbg(log, "lzo decompression buffer too small.\n");
if (dstlen > INT_MAX / 2 + AV_LZO_OUTPUT_PADDING) { if (dstlen >= maxlen / 2) {
talloc_free(dest); talloc_free(dest);
dest = NULL; dest = NULL;
goto error; goto error;