From 417927af3c99bc17819995aa57ae05685deeace8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 11 Dec 2013 16:33:26 +0100 Subject: [PATCH 1/3] hdsenc: Avoid integer overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also remove a silly leftover pair of parentheses. Signed-off-by: Martin Storsjö --- libavformat/hdsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c index 6d5b127a7c..ea6e77c041 100644 --- a/libavformat/hdsenc.c +++ b/libavformat/hdsenc.c @@ -509,7 +509,7 @@ static int hds_write_packet(AVFormatContext *s, AVPacket *pkt) HDSContext *c = s->priv_data; AVStream *st = s->streams[pkt->stream_index]; OutputStream *os = &c->streams[s->streams[pkt->stream_index]->id]; - int64_t end_dts = (os->fragment_index) * c->min_frag_duration; + int64_t end_dts = os->fragment_index * (int64_t) c->min_frag_duration; int ret; if (st->first_dts == AV_NOPTS_VALUE) From b8ed15d6378f00e158c72c526fa0fce17da77361 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 11 Dec 2013 20:17:23 +0100 Subject: [PATCH 2/3] hdsenc: Fix an off by one error in an array size check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/hdsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c index ea6e77c041..c0932933d4 100644 --- a/libavformat/hdsenc.c +++ b/libavformat/hdsenc.c @@ -89,7 +89,7 @@ static int parse_header(OutputStream *os, const uint8_t *buf, int buf_size) if (size > buf_size) return AVERROR_INVALIDDATA; if (type == 8 || type == 9) { - if (os->nb_extra_packets > FF_ARRAY_ELEMS(os->extra_packets)) + if (os->nb_extra_packets >= FF_ARRAY_ELEMS(os->extra_packets)) return AVERROR_INVALIDDATA; os->extra_packet_sizes[os->nb_extra_packets] = size; os->extra_packets[os->nb_extra_packets] = av_malloc(size); From 797f2a791397210ec1b591b326658805c5dbf104 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 12 Dec 2013 21:04:24 +0100 Subject: [PATCH 3/3] hdsenc: Check the init_file() return code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/hdsenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c index c0932933d4..6217c1f51f 100644 --- a/libavformat/hdsenc.c +++ b/libavformat/hdsenc.c @@ -412,7 +412,9 @@ static int hds_write_header(AVFormatContext *s) snprintf(os->temp_filename, sizeof(os->temp_filename), "%s/stream%d_temp", s->filename, i); - init_file(s, os, 0); + ret = init_file(s, os, 0); + if (ret < 0) + goto fail; if (!os->has_video && c->min_frag_duration <= 0) { av_log(s, AV_LOG_WARNING,