From patchwork Sun Apr 25 19:40:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 27367 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp3374565iob; Sun, 25 Apr 2021 12:42:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhwkvGY/MZKW2HRTAIoZran5DEDtQ32cPK3CwndzreG5cqBlgeKeCyaqm5eoznzApl6MSd X-Received: by 2002:a17:906:8a59:: with SMTP id gx25mr4456187ejc.63.1619379730343; Sun, 25 Apr 2021 12:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619379730; cv=none; d=google.com; s=arc-20160816; b=0RLgnQCJPqGmvOUuOwBIbQRLMZcW8ULoLFmpxHZkeg5cdWC5KapzB8VBSD7abShtsV Gp5FKGtuxfCfWsrlzigHXO51jlGBER8w3n3Xq04wPxFWpw2QHhfFsSUUM6ZP5o1JH/ic xX0IH4YJxtWic/9IvFbZVp63abPso+rdLV+MW/ZUTiPi4lJVdKio0J2VBft5PELBpDx3 d/gRh2t2tVHRMUtYsTZiq50goY0LJJCiHRCF3mb/sTheVnKmlZIY4znMKOdy9XIVrVoC YfEYcND76hPL0+60XULKx8X96NN5c+RiR8UVy9c6cIAbCBAGccjzBRfcqa7b5asEeXMR vi8w== 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:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=U3ae8o3SX0eAnflRrGAeYUhK26XUJojZjBhmKpivoqg=; b=HyztDj6iS74mVvC/fY/i2+cEXQlSGrodF9K9at0ZdR6hly7+ztppefibjupUga08zu bS/SGTGDa11MX4Sg978fz9rkkq2OMSJtKgvuspXU4yye3v5rFigj98dD2Fpj+QCpZ+Wn nYSOuIB3NOJUmpUv5BGaFl2LncZTnJWZdcbftgimcdIn9RsGqAOH+z8lOz3v4I7wYTVn ccI/uDPavGbPsh7iqrZ0efiVcyD5Rf40o9FCwvORJJJD0fiq0L6dQvzuMl6npL3/ohfc Jv+EhudKsUSERhB8VNheZLs9AZagGlwZmKVudY3dB7QbRbHnjmbQZ+A+0toeuIMnq9sT UH9A== ARC-Authentication-Results: i=1; mx.google.com; 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 dd3si10578835edb.391.2021.04.25.12.42.09; Sun, 25 Apr 2021 12:42:10 -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; 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 228196880FC; Sun, 25 Apr 2021 22:41:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-3.mx.upcmail.net (vie01a-dmta-pe03-3.mx.upcmail.net [62.179.121.162]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5C413687F49 for ; Sun, 25 Apr 2021 22:41:15 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1lakd1-009wWD-0J for ffmpeg-devel@ffmpeg.org; Sun, 25 Apr 2021 21:41:15 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id akc3lFjcLljeHakc3lu0iJ; Sun, 25 Apr 2021 21:40:15 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=BoHjPrf5 c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=kHjn2dZU96DIAgcTv8QA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=UDnyf2zBuKT2w-IlGP_r:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 25 Apr 2021 21:40:14 +0200 Message-Id: <20210425194014.957-6-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210425194014.957-1-michael@niedermayer.cc> References: <20210425194014.957-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfI1yxvtNz1tA485sq5Ym0PuKZ2ezBhjsnqFlPrV0M78Qf1UR21/vo2fIF3r7trKSgM4ngKtp7E3NGoXFtDbyr1i+vQ7CMkswNX20kPnWenN1jWiBn37Q wwkYwBCJMcOmYiV6544YluTdwryJbQBZZskP4p/oi1jhVg8TTdKAPrbs Subject: [FFmpeg-devel] [PATCH 6/6] avformat/realtextdec: Check the pts difference before using it for the duration computation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: dYsM715lUbuO Fixes: signed integer overflow: 5404200000 - -9223372031709351616 cannot be represented in type 'long' Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_REALTEXT_fuzzer-6737340551790592 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/realtextdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/realtextdec.c b/libavformat/realtextdec.c index f534774420..368a741240 100644 --- a/libavformat/realtextdec.c +++ b/libavformat/realtextdec.c @@ -111,10 +111,11 @@ static int realtext_read_header(AVFormatContext *s) if (!merge) { const char *begin = ff_smil_get_attr_ptr(buf.str, "begin"); const char *end = ff_smil_get_attr_ptr(buf.str, "end"); + int64_t endi = end ? read_ts(end) : 0; sub->pos = pos; sub->pts = begin ? read_ts(begin) : 0; - sub->duration = end ? (read_ts(end) - sub->pts) : duration; + sub->duration = (end && endi > sub->pts && endi - (uint64_t)sub->pts <= INT64_MAX) ? endi - sub->pts : duration; } } av_bprint_clear(&buf);