diff options
Diffstat (limited to 'libavformat/rtpdec_asf.c')
-rw-r--r-- | libavformat/rtpdec_asf.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index d4972bd65d..2c09fda10b 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -2,20 +2,20 @@ * Microsoft RTP/ASF support. * Copyright (c) 2008 Ronald S. Bultje * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -25,6 +25,7 @@ * @author Ronald S. Bultje <rbultje@ronald.bitfreak.net> */ +#include "libavutil/avassert.h" #include "libavutil/base64.h" #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" @@ -53,6 +54,7 @@ static int rtp_asf_fix_header(uint8_t *buf, int len) p += sizeof(ff_asf_guid) + 14; do { uint64_t chunksize = AV_RL64(p + sizeof(ff_asf_guid)); + int skip = 6 * 8 + 3 * 4 + sizeof(ff_asf_guid) * 2; if (memcmp(p, ff_asf_file_header, sizeof(ff_asf_guid))) { if (chunksize > end - p) return -1; @@ -60,9 +62,11 @@ static int rtp_asf_fix_header(uint8_t *buf, int len) continue; } + if (end - p < 8 + skip) + break; /* skip most of the file header, to min_pktsize */ - p += 6 * 8 + 3 * 4 + sizeof(ff_asf_guid) * 2; - if (p + 8 <= end && AV_RL32(p) == AV_RL32(p + 4)) { + p += skip; + if (AV_RL32(p) == AV_RL32(p + 4)) { /* and set that to zero */ AV_WL32(p, 0); return 0; @@ -97,11 +101,12 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) { int ret = 0; if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) { - AVIOContext pb; + AVIOContext pb = { 0 }; RTSPState *rt = s->priv_data; AVDictionary *opts = NULL; int len = strlen(p) * 6 / 8; char *buf = av_mallocz(len); + AVInputFormat *iformat; if (!buf) return AVERROR(ENOMEM); @@ -114,6 +119,10 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) if (rt->asf_ctx) { avformat_close_input(&rt->asf_ctx); } + + if (!(iformat = av_find_input_format("asf"))) + return AVERROR_DEMUXER_NOT_FOUND; + rt->asf_ctx = avformat_alloc_context(); if (!rt->asf_ctx) { av_free(buf); @@ -121,7 +130,13 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) } rt->asf_ctx->pb = &pb; av_dict_set(&opts, "no_resync_search", "1", 0); - ret = avformat_open_input(&rt->asf_ctx, "", &ff_asf_demuxer, &opts); + + if ((ret = ff_copy_whiteblacklists(rt->asf_ctx, s)) < 0) { + av_dict_free(&opts); + return ret; + } + + ret = avformat_open_input(&rt->asf_ctx, "", iformat, &opts); av_dict_free(&opts); if (ret < 0) { av_free(buf); @@ -194,7 +209,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, av_freep(&asf->buf); - ffio_init_context(pb, buf, len, 0, NULL, NULL, NULL, NULL); + ffio_init_context(pb, (uint8_t *)buf, len, 0, NULL, NULL, NULL, NULL); while (avio_tell(pb) + 4 < len) { int start_off = avio_tell(pb); |