summaryrefslogtreecommitdiff
path: root/libavformat/mpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-09-24 22:37:24 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-24 22:39:52 +0200
commiteae3cf06a5410cf6d06235de4ceea28e33e53be3 (patch)
tree126512350cc96249cd1d157969a87a0018f6ab53 /libavformat/mpeg.c
parent0f2297a9b958b8598b17f139e7ec2d7e593a0a7c (diff)
parent2b4e49d4281690db67073ba644ad2ffc17767cdf (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: flvdec: Fix invalid pointer deferences when parsing index configure: disable hardware capabilities ELF section with suncc on Solaris x86 Use explicit struct initializers for AVCodec declarations. Use explicit struct initializers for AVOutputFormat/AVInputFormat declarations. adpcmenc: Set bits_per_coded_sample adpcmenc: fix QT IMA ADPCM encoder adpcmdec: Fix QT IMA ADPCM decoder permit decoding of multichannel ADPCM_EA_XAS Fix input buffer size check in adpcm_ea decoder. fft: avoid a signed overflow mpegps: Handle buffer exhaustion when reading packets. Conflicts: libavcodec/adpcm.c libavcodec/adpcmenc.c libavdevice/alsa-audio-enc.c libavformat/flvdec.c libavformat/mpeg.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mpeg.c')
-rw-r--r--libavformat/mpeg.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index c58e07268a..ad2358124e 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -423,7 +423,7 @@ static int mpegps_read_packet(AVFormatContext *s,
{
MpegDemuxContext *m = s->priv_data;
AVStream *st;
- int len, startcode, i, es_type;
+ int len, startcode, i, es_type, ret;
int request_probe= 0;
enum CodecID codec_id = CODEC_ID_NONE;
enum AVMediaType type;
@@ -569,7 +569,13 @@ static int mpegps_read_packet(AVFormatContext *s,
return AVERROR(EINVAL);
}
av_new_packet(pkt, len);
- avio_read(s->pb, pkt->data, pkt->size);
+ ret = avio_read(s->pb, pkt->data, pkt->size);
+ if (ret < 0) {
+ pkt->size = 0;
+ } else if (ret < pkt->size) {
+ pkt->size = ret;
+ memset(pkt->data + ret, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+ }
pkt->pts = pts;
pkt->dts = dts;
pkt->pos = dummy_pos;
@@ -578,7 +584,7 @@ static int mpegps_read_packet(AVFormatContext *s,
pkt->stream_index, pkt->pts / 90000.0, pkt->dts / 90000.0,
pkt->size);
- return 0;
+ return (ret < 0) ? ret : 0;
}
static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index,