From patchwork Mon Apr 30 22:24:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin NG X-Patchwork-Id: 8701 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp3959791jad; Mon, 30 Apr 2018 15:24:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrljmSabAKN94/O0c9C8npJ1KA5RMKjzUYG7tXxD6nJfCOP+0CuRJHOsfxs83zVh8Det5gd X-Received: by 10.28.146.136 with SMTP id u130mr9081572wmd.125.1525127073568; Mon, 30 Apr 2018 15:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525127073; cv=none; d=google.com; s=arc-20160816; b=vCWoiHNoobv3Ap0P5aQM6Zpse6QDQiCpbknzzBmlNORLJ0tS+JrCE0JcvDrmcKAeEB /Yj8OvYW/cHV8VLuBhZLYVWGmh9nkKEoISkfYBiXDwaJry5CQo0U58Eyz1OpcLFXeNS0 BFhUX3Hs9dVZBiTofnJoAXY1d5dohym4StR0RjV2jNN4ZwotmxsJgH/m13iNqWfgeVCM WiA2fnKloz6Am3o1+Gcg8xVSgW3tmVmCfvAlSgUkYT5iOIw1HYT/mV9bSka6kJU7Q6DQ h/X5pHLsv8L5L1cUwTyz4MMMJAP6NxHE7GZQ9PPA6bHLzJ9h7fKphNSEpDWOYqWFWBJw AF7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=5gMxBn7VWrqR/TlT3VUWnmVZauRCdtb8NhhPKyaFqX0=; b=liyjRSl48PTOYz9bGEEiZoIXmq4GcY8Md06KSMLrF2N0QDZ+IjC7SBTGAUOJfzEu7z VK3NuMcwl8OIzWi1+XBcNPE/6orvHf1wuQhx2C7gzP8jMwc+oQ1VlWVTxkp3YcKKwr5w GUIfJ7NvLg4htW5IBMTdjvBKSCOGruzxetGAD4CkOsyvxN+xCozIMFIeYd86IyOV+gJq 5XQulVQ7qq/M5n0z8GnjTeZkD+d5x/egSNk7benlKLW4KkXwiEQv6PQR3eG0mt5heAWo Y21Exvyp5qAaR/cHzy6DTlDh9+b5qJ64gZ04Pq16DdM0B3b38feUWyUlSGG173HOeQ8h H26A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@hotmail.com header.s=selector1 header.b=qiEuzrip; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=hotmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u80-v6si6952649wrc.154.2018.04.30.15.24.33; Mon, 30 Apr 2018 15:24:33 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@hotmail.com header.s=selector1 header.b=qiEuzrip; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=hotmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5082C68A36E; Tue, 1 May 2018 01:23:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-oln040092003090.outbound.protection.outlook.com [40.92.3.90]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CA49868A35F for ; Tue, 1 May 2018 01:23:50 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=I6x1tsY4slnfzv5nGUzgHbRFD726JoWWlyFD/QJVnjE=; b=qiEuzripNKzLpNgp4IGS0cbKo10OaVL4XZYDrn1DMoyv5AYPNanKEAO8wIFI367U1+ZVuF+ksFK+p0DtTWUAvh5gJDjDsj9vZ0iSUT87MJ2Tk1U92F+iTUV+fqo2+KXp22LDrCn6BIh1YghVJquueYAoBWaqB28BPYIOUcdV+Wl7sDG3Fkd1FqocJRk3g7U7f/Te4vAWmy4gfKA9Yt4SULvUxB2y4nehibip4YMcOnEbr4IgaxB1vdW6u2pcfXuSUkmiLOlYjHjQrwl+ETmxP6aA5liRZUglZbGXF+Nrs8fMHj2IsdoIlHNbGZPxVoGpgUXqKjOgE3YYedwFKzv29A== Received: from BL2NAM02FT041.eop-nam02.prod.protection.outlook.com (10.152.76.51) by BL2NAM02HT222.eop-nam02.prod.protection.outlook.com (10.152.77.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.715.13; Mon, 30 Apr 2018 22:24:21 +0000 Received: from DM5PR22MB0681.namprd22.prod.outlook.com (10.152.76.51) by BL2NAM02FT041.mail.protection.outlook.com (10.152.77.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.715.13 via Frontend Transport; Mon, 30 Apr 2018 22:24:21 +0000 Received: from DM5PR22MB0681.namprd22.prod.outlook.com ([fe80::3050:f9e1:7035:9927]) by DM5PR22MB0681.namprd22.prod.outlook.com ([fe80::3050:f9e1:7035:9927%18]) with mapi id 15.20.0715.018; Mon, 30 Apr 2018 22:24:21 +0000 From: Colin NG To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH 2/2] libavformat/dashdec: Fix for ticket 7149 (Segfault when decoding dash streams) Thread-Index: AQHT4NH8yXCvlFZzJk+DrYR5w1g7+A== Date: Mon, 30 Apr 2018 22:24:21 +0000 Message-ID: References: <1525126976-37955-1-git-send-email-colin_ng@hotmail.com> In-Reply-To: <1525126976-37955-1-git-send-email-colin_ng@hotmail.com> Accept-Language: en-CA, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: YQBPR0101CA0036.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00::49) To DM5PR22MB0681.namprd22.prod.outlook.com (2603:10b6:3:fb::23) x-incomingtopheadermarker: OriginalChecksum:E852522309E4A3FA7FC1730E93D6F6AD5805D615E7082E5F3E4BDA7A70AE5246; UpperCasedChecksum:B4ECD7B148055BC8CFA2EF9E10AB3F2CA68481074859E4539994DB07FFB43149; SizeAsReceived:7518; Count:50 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [MnwJ6oXQO/moiObwGY8He9PL0gFoxNeL] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BL2NAM02HT222; 7:qClhNZr7eW39kfNQIKeUrNee2OkoK/PV3sVl4UXLVRNZhNJORfLrvBnodZ9vdP0WLL6/K/dhZ0TgvchSh7VQiKo1/PyOzQZwGfEEZ9KTTRIz+RE0ORUprfW7WMHM3Xw+1pFTsC9Kg8CVDeQ7ymO48l1ZyqHcUZXtShslYeKIQxxuIK39ZGccayfYfvYCSkZ2FClztfO8VVG1GVbWGoN4rK+MdVSiWTgZQaJWEgNh03jXfKDPKlN7LR2gfrHyYGdn x-incomingheadercount: 50 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(201702181274)(2017031322404)(1601125374)(1603101448)(1701031045); SRVR:BL2NAM02HT222; x-ms-exchange-slblob-mailprops: gjx25WM8ZNWDLNYE1270853gEtvkFpW2iWxIvMt4xdgzgJe7HpjsDgXf9lxIuB9SCocjDPA9ExJg1J280vHzfr6zCLZRl9M+dmcgdGUvzx1lvQCa1akpHCBrlJrcdyVE4UrVlHXuCPiZs4NrrlcuCML+d++MZozmBwds4VtmBz5RKVdUr0EXHpKjvlG4n7ueXBRdi9JuInpx8ydWIMe7Q4U0KgvsHY3nDAZp0HHl1QVvVBSPfREWoy2xkXDB+tH5O55/+uxIaJKbs2YEKghjtMmnIOajKk7bO3DfvKQyFj78ioElO3lvcoKb8xRzIJOJdOh6AcTm4GevAmpNxB/IW6mTMYtQo36XakpHN9yQUD7NN9DYRVgdlVTZTo29naa+XllGtkc5Wq74i8dMXQLWfwyAWCq2FssDVPTjQZGHrK+f16uFY2PqP4iVR+fFESLOGyuD9hDVxgdUeakcK8tx0Hcc1w4Kta53s5MX2a1HGjfoIC9pUp6Qd+yp/kFRvQ6yywK+PGRGAR5bctBZrZJlS0j/NpZhsO1NnFmsJ3MKObu5lsEeKrg1nuZq9daXAClNs2dVNTgIfcS/yXsoznxKHAR1iLWH6VAFNRWzF5RoTRMPJbTzbMn8jAbwuVMW9dmekRpfM8U/kBHEBF+tsx76cfox1Vk8X28TNDoLR5rdVwQxnpDj/XlYt+JdM6uSY9xMkMpzUAYxhZYr/ZPBAYVCu3etM7JR9yOFbM6go1RvQXc= x-ms-traffictypediagnostic: BL2NAM02HT222: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:BL2NAM02HT222; BCL:0; PCL:0; RULEID:; SRVR:BL2NAM02HT222; x-forefront-prvs: 0658BAF71F x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(98901004); DIR:OUT; SFP:1901; SCL:1; SRVR:BL2NAM02HT222; H:DM5PR22MB0681.namprd22.prod.outlook.com; FPR:; SPF:None; LANG:; x-microsoft-antispam-message-info: y75f049VHCyC2Hsn+Vub2Gez/e4XjAYjHVcPxKKrAFnSr6sZdgEyTvrf5xfrHLMPHFyS1DNh0vkLzlt08Flrfo50moijEGRB1P9C/K/9QVbXfkhprFEJ7FqSxkPZcOTjyljSj97OToBJkvuFhpZl2IuK5fQG+HQQHWLJxUbHQzD9gmb9fKt+VhED+XQCsxcK MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 7d309de3-9946-4444-8aec-08d5aee91ea6 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 9bd8b953-1c55-4da7-b616-8bcad099ae8b X-MS-Exchange-CrossTenant-Network-Message-Id: 7d309de3-9946-4444-8aec-08d5aee91ea6 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 9bd8b953-1c55-4da7-b616-8bcad099ae8b X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Apr 2018 22:24:21.3574 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT222 Subject: [FFmpeg-devel] [PATCH 2/2] libavformat/dashdec: Fix for ticket 7149 (Segfault when decoding dash streams) X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Colin NG Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" - simplify the code to check common init section --- libavformat/dashdec.c | 48 +++++++++++------------------------------------- 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index c6f350d..acaa1bf 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1875,43 +1875,22 @@ fail: return ret; } -static int init_section_compare_video(DASHContext *c) +static int is_common_init_section_exist(struct representation **pls, int n_pls) { + struct fragment *first_init_section = pls[0]->init_section; char *url =NULL; int64_t url_offset = -1; int64_t size = -1; int i = 0; - if (c->videos[0]->init_section == NULL) + if (first_init_section == NULL || n_pls == 0) return 0; - url = c->videos[0]->init_section->url; - url_offset = c->videos[0]->init_section->url_offset; - size = c->videos[0]->init_section->size; - for (i=0;in_videos;i++) { - if (av_strcasecmp(c->videos[i]->init_section->url,url) || c->videos[i]->init_section->url_offset != url_offset || c->videos[i]->init_section->size != size) { - return 0; - } - } - - return 1; -} - -static int init_section_compare_audio(DASHContext *c) -{ - char *url =NULL; - int64_t url_offset = -1; - int64_t size = -1; - int i = 0; - - if (c->audios[0]->init_section == NULL) - return 0; - - url = c->audios[0]->init_section->url; - url_offset = c->audios[0]->init_section->url_offset; - size = c->audios[0]->init_section->size; - for (i=0; in_audios; i++) { - if (av_strcasecmp(c->audios[i]->init_section->url,url) || c->audios[i]->init_section->url_offset != url_offset || c->audios[i]->init_section->size != size) { + url = first_init_section->url; + url_offset = first_init_section->url_offset; + size = pls[0]->init_section->size; + for (i=0;iinit_section->url,url) || pls[i]->init_section->url_offset != url_offset || pls[i]->init_section->size != size) { return 0; } } @@ -1957,9 +1936,7 @@ static int dash_read_header(AVFormatContext *s) s->duration = (int64_t) c->media_presentation_duration * AV_TIME_BASE; } - if (c->n_videos) { - c->is_init_section_common_video = init_section_compare_video(c); - } + c->is_init_section_common_video = is_common_init_section_exist(c->videos, c->n_videos); /* Open the demuxer for video and audio components if available */ for (i = 0; i < c->n_videos; i++) { @@ -1975,11 +1952,8 @@ static int dash_read_header(AVFormatContext *s) ++stream_index; } - - if (c->n_audios) { - c->is_init_section_common_audio = init_section_compare_audio(c); - } - + c->is_init_section_common_audio = is_common_init_section_exist(c->audios, c->n_audios); + for (i = 0; i < c->n_audios; i++) { struct representation *cur_audio = c->audios[i]; if (i > 0 && c->is_init_section_common_audio) {