From patchwork Fri Dec 13 00:28:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 16768 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 A746F448848 for ; Fri, 13 Dec 2019 04:07:35 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7865F68A2FA; Fri, 13 Dec 2019 04:07:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-2.mx.upcmail.net (vie01a-dmta-pe06-2.mx.upcmail.net [84.116.36.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 00E71689B8C for ; Fri, 13 Dec 2019 04:07:28 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1ifYrV-0007MT-FU for ffmpeg-devel@ffmpeg.org; Fri, 13 Dec 2019 01:31:17 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id fYqXizHUVwlysfYqXieLhl; Fri, 13 Dec 2019 01:30:17 +0100 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=E5OzWpVl c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=npHnxyVkhCkBe7R9DbwA:9 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 13 Dec 2019 01:28:10 +0100 Message-Id: <20191213002810.6440-5-michael@niedermayer.cc> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191213002810.6440-1-michael@niedermayer.cc> References: <20191213002810.6440-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfNZBFjePfF+zFXQ3y0c3EWuvp0fNM5suNlpeLlhRLWF3aMzjyIefiHCnKnX4ptY/9zQHOxFItS51vWg7VJTC3cjtMMvVYLLfSR1IhRvBZxgns2YJvh70 +Oz6o4Q9t5aFpLsLDTqMO9k9dJza1xYGmeb42HwNBJSuriqilpI2ey+0 Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/hevc_mp4toannexb_bsf: Check that there is enough input left for nalu size 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" No testcase Signed-off-by: Michael Niedermayer --- libavcodec/hevc_mp4toannexb_bsf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c index baa93628ed..e0d20a550c 100644 --- a/libavcodec/hevc_mp4toannexb_bsf.c +++ b/libavcodec/hevc_mp4toannexb_bsf.c @@ -152,7 +152,9 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) extra_size = add_extradata * ctx->par_out->extradata_size; got_irap |= is_irap; - if (FFMIN(INT_MAX, SIZE_MAX) < 4ULL + nalu_size + extra_size) { + if (FFMIN(INT_MAX, SIZE_MAX) < 4ULL + nalu_size + extra_size || + bytestream2_get_bytes_left(&gb) < nalu_size + ) { ret = AVERROR_INVALIDDATA; goto fail; }