From patchwork Sat Jul 6 14:18:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13836 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2C73C449D3B for ; Sat, 6 Jul 2019 17:26:12 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 12FF868AD04; Sat, 6 Jul 2019 17:26:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A521868ACFA for ; Sat, 6 Jul 2019 17:26:05 +0300 (EEST) Received: by mail-wm1-f43.google.com with SMTP id p74so8681399wme.4 for ; Sat, 06 Jul 2019 07:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kssY9kGF2q4VHaOAwmg7cUawi+BkO13qGPnst50VWag=; b=VBpwEfMh0aNWFiIHJTLGHkfVYnPvBaXQpXMi2vdMtV5Ca2AoNaC77rss9Azk3FRjF7 2m6HdBDt95xTKgUNx7RKga6tZmal3lBBrswCrxg2bJOUdTZiXAo+ARBzNd/Tnc48ncJe 0tr+MHViIffcrULcdu1Llw5zXdIHzkT0aybWlIolzywIxHu1PjvnrIns3o7137A3ZHQR Xl2DHWNzehJ+Gu/bklSPCmWA28T1hlkZUOOFUt2yElxah2q7O6KBob8MjNNpcuzfUx7j T3Xv5tsUTqQ+N411YzRX/TyiwiJ1yNnsnDuwuUFQs/yP3cJKogLl3qbMhif1HwFM/Aqv vqxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kssY9kGF2q4VHaOAwmg7cUawi+BkO13qGPnst50VWag=; b=cqUMrGaJ9lOuo7qJP4Ov6W0TiRqrhO5RtdtgWuL+sJYOY+aot+ty1aNzn9LoFdcdYJ bIwaEWQh/UfVycVdnGIsSjAQEHd9z1/bWY9GSurs4U75ZgdudjzxOJfwj8mgDX4Ofi2p FW7GqNE2z81b70EZCeWs/GbCcl6EwHim1LWUbB1f/Rby3vyUtyCkKSdX7irKtknHKAfJ 5FptLSY7hvYB6XEFsZ0ErUTsDoy4fKyPkYnS0/SRoUPCIMpNbli/4WV6F3KoeLFnh/W5 4Rq66ao8tDybbP9TzdYFfVBolOzkKgKVuT2xG+uuKXQd0uYtvnm+16cPs5ZHfrWcntr+ Bt3A== X-Gm-Message-State: APjAAAWpVhSFONVrR+Zw6xmBpdOoM/MXsz3vHRllAZ8x8Ggrrjez+e/l UMd80XilKgJ1c0zpcGhh5RU44v4AugI= X-Google-Smtp-Source: APXvYqxxd4mtBaQdaHIND3z31blO8MQo+0a3wLjDjJlIZ2zW9o6JgM7wynz7DIQ0e18GmBWz8NK34A== X-Received: by 2002:a1c:f116:: with SMTP id p22mr8169191wmh.70.1562422700431; Sat, 06 Jul 2019 07:18:20 -0700 (PDT) Received: from localhost.localdomain (ipbcc08b8f.dynamic.kabel-deutschland.de. [188.192.139.143]) by smtp.gmail.com with ESMTPSA id z7sm1331566wrh.67.2019.07.06.07.18.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 06 Jul 2019 07:18:20 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 Jul 2019 16:18:01 +0200 Message-Id: <20190706141804.12034-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190706141804.12034-1-andreas.rheinhardt@gmail.com> References: <20190706135911.11986-1-andreas.rheinhardt@gmail.com> <20190706141804.12034-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] truehd_core: Return error in case of error 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Several checks (e.g. when the size of the input packet is too small) simply used "goto fail", but didn't set the return value appropriately for an error. Signed-off-by: Andreas Rheinhardt --- libavcodec/truehd_core_bsf.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavcodec/truehd_core_bsf.c b/libavcodec/truehd_core_bsf.c index 83f2b16e3d..f858c2d4d5 100644 --- a/libavcodec/truehd_core_bsf.c +++ b/libavcodec/truehd_core_bsf.c @@ -53,8 +53,10 @@ static int truehd_core_filter(AVBSFContext *ctx, AVPacket *out) if (ret < 0) return ret; - if (in->size < 4) + if (in->size < 4) { + ret = AVERROR_INVALIDDATA; goto fail; + } ret = init_get_bits(&gbc, in->data, 32); if (ret < 0) @@ -62,8 +64,10 @@ static int truehd_core_filter(AVBSFContext *ctx, AVPacket *out) skip_bits(&gbc, 4); in_size = get_bits(&gbc, 12) * 2; - if (in_size < 4 || in_size > in->size) + if (in_size < 4 || in_size > in->size) { + ret = AVERROR_INVALIDDATA; goto fail; + } out_size = in_size; dts = get_bits(&gbc, 16); @@ -73,13 +77,15 @@ static int truehd_core_filter(AVBSFContext *ctx, AVPacket *out) goto fail; if (show_bits_long(&gbc, 32) == 0xf8726fba) { - if ((ret = ff_mlp_read_major_sync(ctx, &s->hdr, &gbc)) != 0) + if ((ret = ff_mlp_read_major_sync(ctx, &s->hdr, &gbc)) < 0) goto fail; have_header = 1; } - if (s->hdr.num_substreams > MAX_SUBSTREAMS) + if (s->hdr.num_substreams > MAX_SUBSTREAMS) { + ret = AVERROR_INVALIDDATA; goto fail; + } for (i = 0; i < s->hdr.num_substreams; i++) { for (int j = 0; j < 4; j++)