From patchwork Sat Jan 20 07:07:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan McGrath X-Patchwork-Id: 7359 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.156.27 with SMTP id q27csp438852jak; Fri, 19 Jan 2018 23:07:34 -0800 (PST) X-Google-Smtp-Source: AH8x2271V15OuMkVwYxDwN8r6ahKtlkZ1l6wXq/JCH8J3g933hFzsF9UVYZEnz6L/z71kPAXs+lO X-Received: by 10.223.184.14 with SMTP id h14mr858801wrf.31.1516432054406; Fri, 19 Jan 2018 23:07:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516432054; cv=none; d=google.com; s=arc-20160816; b=DD24GhQTw9fW2RQ7xTmjyYpZaGeJ5e/sIxlKfbT74D1AvMglyfwjHh1ACQI95MeNX1 ilJE3GX/pzKPdd4Ge5Bhyw5t00H+agmeLjQHXf5g1giyYUjcrS0/mMTLEbDAlLyfoRT0 eaRmrooxAEXZrZECU7fhD8VC/5XlmaheJEizqyfaMlrgyygJEEMpw47cyPhpJ8O4yyRP IBdV4yULQcpislB//Cy5LZVxFwHO0FuULq6RsfUZYkbu6MoTtv5Pubz/4bcr3wNndN8x vtTOqK5wDIwLG6eUWdJAyOWYcqeVxDbTXFba1YVsJxcQcZJh2YYp1z15SNgE490Gud+n TGmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=iTTbHV9bpUB8mxE4OJEA/3PmnscdL6Xb2l10xqg/UEU=; b=hXHtZFBn0LDMer2vRGAptJjmLx4NPy01phqDYtLJEH/qKCwqg0eHVINoZloVF5qh05 ScmrPR7W4LkjYEes+3iIQyBB61tKj8flFxv+LaghuOsQthUZMJhf+wXnEHKHP6FJUZkw V3O9x4uxM3x7h7952UtlO9zRSH/0Yy+94YefagGsqzvsjdTfJOaYNWT4K3zqHmjhO8Y0 RbUoJCyul7d4L+U83O1cYNOBysSeHyUcCK0FCChouU6CWn8JCrwC7ImHbGSYBTOcvxVw T6ZjxXZFbgmKRQa4mMg8ZHIiRKB+peWJ6q+Xl3fmBf2oRYXmPHvRCpudfVVy+l8WTOP5 gC1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@hermana.com.au header.s=2016 header.b=b9SZ6iLv; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b69si1826348wme.106.2018.01.19.23.07.33; Fri, 19 Jan 2018 23:07:34 -0800 (PST) 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=@hermana.com.au header.s=2016 header.b=b9SZ6iLv; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C062689EA9; Sat, 20 Jan 2018 09:07:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.hermana.com.au (ec2-13-54-119-68.ap-southeast-2.compute.amazonaws.com [13.54.119.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2734B6899F8 for ; Sat, 20 Jan 2018 09:07:24 +0200 (EET) Received: from brendan-desktop.localdomain (2001-44b8-412c-1c00-3def-8e15-6d55-724d.static.ipv6.internode.on.net [IPv6:2001:44b8:412c:1c00:3def:8e15:6d55:724d]) by mail.hermana.com.au (Postfix) with ESMTPSA id 1D57EDC; Sat, 20 Jan 2018 07:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hermana.com.au; s=2016; t=1516432042; bh=sRYYeo9HEXY2Vm7gye2c4Jydn54zF/xSrEj7ylrwMjM=; h=From:To:Cc:Subject:Date:From; b=b9SZ6iLvj8E8vTjV0HNIHw6zy5K5o8n0MFIhCaFasWD8uQDKyiCtPdfg7lNRa8Of3 /To9M8KjSYVs13V+rwOz1agoJR2q65PcCT9Tr/MnAKm8YYwBlFYOVbZ2Ie7ocU9Y7k D7yIDpwohi3Ot4ZWerV0eRu6Z0Ty2FvmM0zU0aY4= From: Brendan McGrath To: ffmpeg-devel@ffmpeg.org, Steven Liu Date: Sat, 20 Jan 2018 18:07:12 +1100 Message-Id: <1516432032-4465-1-git-send-email-redmcg@redmandi.dyndns.org> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH] dashdec: Fix segfault on decoding segment timeline 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: Brendan McGrath MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" If first_seq_no is not within the bounds of timelines then a segfault will occur. This patch removes the use of first_seq_no within the timelines array It also adds first_seq_no to the value returned by calc_next_seg_no_from_timelines (which allows for different values of 'startNumber') Signed-off-by: Brendan McGrath --- This can be reproduced by creating a dash file with the following command: ffmpeg -i in.ts -f dash -window_size 2 out.mpd and then after about 10 seconds run ffprobe against it. The SegementTemplatei of out.mpd will look something like this: So the code was trying to access the 7th element within the timeline array (which only had one element). The patch doesn't worry about checking for a negative value after deducting the 60 seconds as calc_next_seg_no_from_timelines accepts a signed int and works correctly with negative values. libavformat/dashdec.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 2492f1d..cdb7ba5 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1083,15 +1083,12 @@ static int64_t calc_cur_seg_no(AVFormatContext *s, struct representation *pls) if (pls->n_fragments) { num = pls->first_seq_no; } else if (pls->n_timelines) { - start_time_offset = get_segment_start_time_based_on_timeline(pls, 0xFFFFFFFF) - pls->timelines[pls->first_seq_no]->starttime; // total duration of playlist - if (start_time_offset < 60 * pls->fragment_timescale) - start_time_offset = 0; - else - start_time_offset = start_time_offset - 60 * pls->fragment_timescale; - - num = calc_next_seg_no_from_timelines(pls, pls->timelines[pls->first_seq_no]->starttime + start_time_offset); + start_time_offset = get_segment_start_time_based_on_timeline(pls, 0xFFFFFFFF) - 60 * pls->fragment_timescale; // 60 seconds before end + num = calc_next_seg_no_from_timelines(pls, start_time_offset); if (num == -1) num = pls->first_seq_no; + else + num += pls->first_seq_no; } else if (pls->fragment_duration){ if (pls->presentation_timeoffset) { num = pls->presentation_timeoffset * pls->fragment_timescale / pls->fragment_duration;