From patchwork Sun Oct 23 16:30:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Cadhalpun X-Patchwork-Id: 1149 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp1838131vsd; Sun, 23 Oct 2016 09:30:36 -0700 (PDT) X-Received: by 10.28.170.204 with SMTP id t195mr10740856wme.113.1477240236847; Sun, 23 Oct 2016 09:30:36 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q1si12100216wjd.199.2016.10.23.09.30.36; Sun, 23 Oct 2016 09:30:36 -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=@googlemail.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; dmarc=fail (p=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6BEC6689CE9; Sun, 23 Oct 2016 19:30:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 77531689CC9 for ; Sun, 23 Oct 2016 19:30:24 +0300 (EEST) Received: by mail-wm0-f68.google.com with SMTP id d128so6304337wmf.0 for ; Sun, 23 Oct 2016 09:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=yuiFUkv3PYCnvwvDv13jbZvoh60RTJtKbIooqpmrUu4=; b=DtLwle4mNZ/SjbL2ZzVWIed9azw/wU/hm+h1gxLlVkXiS/66pczTeuY/87b6B7pPUY dRGPuKES12emtZLmiP214mWxYRi3Mhgtn95zVLRnq6Jtq6m/Y2WTTSXiFvNQyQvsv6k5 oFmXxh224obn/9RyWJagnzKJ83RJXOeHYzxaXgnq5PbvxdFzr7dmDcz8fWre/GaVL/l0 MMH8WyAKnVz+YRTnN7Wz4L9HS/4u+mfdj3qLdINcvHXWLRIs28YyVU2and3ztTXIbkVi QLo1h0mEMPWzU/Z2OjNIGk0uNofmTPNhWPgWPI8LZ8UxSy+SDFBFtjuqauzIs6hbKrez gvTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=yuiFUkv3PYCnvwvDv13jbZvoh60RTJtKbIooqpmrUu4=; b=h4jvNwudtz8MrtgFOrn5Km3+gcPGuILE+bmt7r0sWFfO5Bz5VbQsmTTDQwyWIKWUnA 96/yn8FtWGfBluMktsPfzxLq5PrCWQs28Fjcvnplt5r0q93n8ZUfp/bP2QcHdZlOir++ Be0XE9VFSYpUOZO73GV7Oy0Vx0YlkK3PY5yX6hdtCOU4U1q99GvSw5lNPAT07PgvdX2x 7TbVqyMo5nOmXKSuv3ZtCcjNmcjLtfMIINSSPAVHDFWANBe1cTU2UjfNhwQo0X43qGnv 4gND681fHZumJXnM6Hx1UgxgUP/AmtltU2QQLLEsyDlilFvGdl+YhlcCEGZPvaB7Xob7 jtpg== X-Gm-Message-State: AA6/9RkVvz3vXmVP9aC7w7DPr/Isf73/0LXBskwsMrhQwwja45gTwOB3CMXYpU+PeTp1vA== X-Received: by 10.28.24.139 with SMTP id 133mr18992956wmy.103.1477240227168; Sun, 23 Oct 2016 09:30:27 -0700 (PDT) Received: from [192.168.2.21] (p5B095E5A.dip0.t-ipconnect.de. [91.9.94.90]) by smtp.googlemail.com with ESMTPSA id o62sm9984145wmg.12.2016.10.23.09.30.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Oct 2016 09:30:26 -0700 (PDT) From: Andreas Cadhalpun X-Google-Original-From: Andreas Cadhalpun To: FFmpeg development discussions and patches References: <6622a3c7-3900-8982-1179-4ccdd0fec2b3@googlemail.com> Message-ID: <8e483f51-1b67-d0ce-cd0a-695ac978ca9f@googlemail.com> Date: Sun, 23 Oct 2016 18:30:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: <6622a3c7-3900-8982-1179-4ccdd0fec2b3@googlemail.com> Subject: [FFmpeg-devel] [PATCH 09/12] nuv: validate sample_rate 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" A negative sample rate doesn't make sense and triggers assertions in av_rescale_rnd. Signed-off-by: Andreas Cadhalpun --- libavformat/nuv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/nuv.c b/libavformat/nuv.c index d920250..9bdea4a 100644 --- a/libavformat/nuv.c +++ b/libavformat/nuv.c @@ -66,7 +66,7 @@ static int nuv_probe(AVProbeData *p) * @param myth set if this is a MythTVVideo format file * @return 0 or AVERROR code */ -static int get_codec_data(AVIOContext *pb, AVStream *vst, +static int get_codec_data(AVFormatContext *s, AVIOContext *pb, AVStream *vst, AVStream *ast, int myth) { nuv_frametype frametype; @@ -114,6 +114,10 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst, ast->codecpar->codec_tag = avio_rl32(pb); ast->codecpar->sample_rate = avio_rl32(pb); + if (ast->codecpar->sample_rate <= 0) { + av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", ast->codecpar->sample_rate); + return AVERROR_INVALIDDATA; + } ast->codecpar->bits_per_coded_sample = avio_rl32(pb); ast->codecpar->channels = avio_rl32(pb); ast->codecpar->channel_layout = 0; @@ -232,7 +236,7 @@ static int nuv_header(AVFormatContext *s) } else ctx->a_id = -1; - if ((ret = get_codec_data(pb, vst, ast, is_mythtv)) < 0) + if ((ret = get_codec_data(s, pb, vst, ast, is_mythtv)) < 0) return ret; ctx->rtjpg_video = vst && vst->codecpar->codec_id == AV_CODEC_ID_NUV;