allocate a few bytes more for extradata so the bitstream reader if its used by the codec for parsing extardata, doesnt read over the end

Originally committed as revision 3679 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Michael Niedermayer 20 years ago
parent 4940ed6ae1
commit 3129cd0140
  1. 2
      libavformat/asf.c
  2. 2
      libavformat/avidec.c
  3. 4
      libavformat/mov.c
  4. 2
      libavformat/nut.c
  5. 2
      libavformat/ogg.c
  6. 2
      libavformat/rtsp.c
  7. 2
      libavformat/wav.c

@ -274,7 +274,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
url_fskip(pb, 20); url_fskip(pb, 20);
if (size > 40) { if (size > 40) {
st->codec.extradata_size = size - 40; st->codec.extradata_size = size - 40;
st->codec.extradata = av_mallocz(st->codec.extradata_size); st->codec.extradata = av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(pb, st->codec.extradata, st->codec.extradata_size); get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
} }

@ -301,7 +301,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_le32(pb); /* ClrImportant */ get_le32(pb); /* ClrImportant */
st->codec.extradata_size= size - 10*4; st->codec.extradata_size= size - 10*4;
st->codec.extradata= av_malloc(st->codec.extradata_size); st->codec.extradata= av_malloc(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(pb, st->codec.extradata, st->codec.extradata_size); get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
if(st->codec.extradata_size & 1) //FIXME check if the encoder really did this correctly if(st->codec.extradata_size & 1) //FIXME check if the encoder really did this correctly

@ -569,7 +569,7 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
#ifdef DEBUG #ifdef DEBUG
av_log(NULL, AV_LOG_DEBUG, "Specific MPEG4 header len=%d\n", len); av_log(NULL, AV_LOG_DEBUG, "Specific MPEG4 header len=%d\n", len);
#endif #endif
st->codec.extradata = (uint8_t*) av_mallocz(len); st->codec.extradata = (uint8_t*) av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec.extradata) { if (st->codec.extradata) {
get_buffer(pb, st->codec.extradata, len); get_buffer(pb, st->codec.extradata, len);
st->codec.extradata_size = len; st->codec.extradata_size = len;
@ -680,7 +680,7 @@ static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
// this should be fixed and just SMI header should be passed // this should be fixed and just SMI header should be passed
av_free(st->codec.extradata); av_free(st->codec.extradata);
st->codec.extradata_size = 0x5a + atom.size; st->codec.extradata_size = 0x5a + atom.size;
st->codec.extradata = (uint8_t*) av_mallocz(st->codec.extradata_size); st->codec.extradata = (uint8_t*) av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec.extradata) { if (st->codec.extradata) {
strcpy(st->codec.extradata, "SVQ3"); // fake strcpy(st->codec.extradata, "SVQ3"); // fake

@ -982,7 +982,7 @@ static int decode_stream_header(NUTContext *nut){
/* codec specific data headers */ /* codec specific data headers */
while(get_v(bc) != 0){ while(get_v(bc) != 0){
st->codec.extradata_size= get_v(bc); st->codec.extradata_size= get_v(bc);
st->codec.extradata= av_mallocz(st->codec.extradata_size); st->codec.extradata= av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(bc, st->codec.extradata, st->codec.extradata_size); get_buffer(bc, st->codec.extradata, st->codec.extradata_size);
// url_fskip(bc, get_v(bc)); // url_fskip(bc, get_v(bc));
} }

@ -196,7 +196,7 @@ static int ogg_read_header(AVFormatContext *avfcontext, AVFormatParameters *ap)
return -1; return -1;
} }
codec->extradata_size+= 2 + op.bytes; codec->extradata_size+= 2 + op.bytes;
codec->extradata= av_realloc(codec->extradata, codec->extradata_size); codec->extradata= av_realloc(codec->extradata, codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
p= codec->extradata + codec->extradata_size - 2 - op.bytes; p= codec->extradata + codec->extradata_size - 2 - op.bytes;
*(p++)= op.bytes>>8; *(p++)= op.bytes>>8;
*(p++)= op.bytes&0xFF; *(p++)= op.bytes&0xFF;

@ -211,7 +211,7 @@ static void sdp_parse_fmtp(AVCodecContext *codec, const char *p)
if (!strcmp(attr, "config")) { if (!strcmp(attr, "config")) {
/* decode the hexa encoded parameter */ /* decode the hexa encoded parameter */
len = hex_to_data(NULL, value); len = hex_to_data(NULL, value);
codec->extradata = av_mallocz(len); codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata) if (!codec->extradata)
goto fail; goto fail;
codec->extradata_size = len; codec->extradata_size = len;

@ -154,7 +154,7 @@ void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size)
if (codec->extradata_size > 0) { if (codec->extradata_size > 0) {
if (codec->extradata_size > size - 18) if (codec->extradata_size > size - 18)
codec->extradata_size = size - 18; codec->extradata_size = size - 18;
codec->extradata = av_mallocz(codec->extradata_size); codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(pb, codec->extradata, codec->extradata_size); get_buffer(pb, codec->extradata, codec->extradata_size);
} else } else
codec->extradata_size = 0; codec->extradata_size = 0;

Loading…
Cancel
Save