Skip to content

Commit

Permalink
avformat/apngdec: Make sure that extradata is zero-padded
Browse files Browse the repository at this point in the history
Zeroing the padding has been forgotten.

Signed-off-by: Andreas Rheinhardt <[email protected]>
Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
mkver authored and michaelni committed Dec 12, 2019
1 parent 56ce2ad commit 2e328a8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libavformat/apngdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ static int append_extradata(AVCodecParameters *par, AVIOContext *pb, int len)
int new_size, ret;
uint8_t *new_extradata;

if (previous_size > INT_MAX - len)
if (previous_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - len)
return AVERROR_INVALIDDATA;

new_size = previous_size + len;
new_extradata = av_realloc(par->extradata, new_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!new_extradata)
return AVERROR(ENOMEM);
memset(new_extradata + new_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
par->extradata = new_extradata;
par->extradata_size = new_size;

Expand Down Expand Up @@ -177,10 +178,9 @@ static int apng_read_header(AVFormatContext *s)
return ret;

/* extradata will contain every chunk up to the first fcTL (excluded) */
st->codecpar->extradata = av_malloc(len + 12 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
st->codecpar->extradata_size = len + 12;
ret = ff_alloc_extradata(st->codecpar, len + 12);
if (ret < 0)
return ret;
AV_WB32(st->codecpar->extradata, len);
AV_WL32(st->codecpar->extradata+4, tag);
AV_WB32(st->codecpar->extradata+8, st->codecpar->width);
Expand Down

0 comments on commit 2e328a8

Please sign in to comment.