From patchwork Wed Dec 6 23:09:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 6571 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp7567829jah; Wed, 6 Dec 2017 15:09:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMakvBTx3S46RUR1jeAFLP5KpF5vqZ7ueOWil3Cl4pyI/EsogLEasznlfRpWJb3iXQ32OLF8 X-Received: by 10.28.193.66 with SMTP id r63mr12536764wmf.18.1512601778238; Wed, 06 Dec 2017 15:09:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512601778; cv=none; d=google.com; s=arc-20160816; b=iNfAWjomkxXpIs13DnUxfqApasP2Xsaag5mmoips9KT51OfNCFkZJ8xDlDC05KO6pK +ywos7geaVkmOXKS3bdN2+52LMQXdAtA/nOcwFfyYDZ5ELsK2HiZrB4VYUPyIZ2aOEtU TONcQSfsf0dPnyAxjcsqu0kkyOKWeztwRIuGVp58EcKqZdgakPw7pSybJszDTfalUrP8 lZwBxm/Ut3eMpYrnaFS8bMB1gj5DxKGYVIRgmRjcZ0UN2RwjfqNAz/YeDZEQeXbwV5dc 5nbMjWRGftLMDd5gpGsadeyPo1y7YWIChUTDp4pWKrIxu8mVyOtZMOhTHCCVx9YiNsLL dL4A== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=PVLxFaPhbp+TtSdQvfLzTqdJb2vdoqYrxY3MeVAuuf8=; b=VN9tG5vkobiu6uWtjQrZKb742B4J0S55Bbh/RcHNiUbGGmG60ayPUm+7bDLBPND3E2 7iTDIHFmFuolzYmCmAa2zV1++XSwBvtbHPvgG2SHTOinR9Hxpt6odUIqwpDYFcAvfHVD VpqQi0uZaP/5oUaAGkP9K00s2Cx1Kl8mIzZ5JTwadS+6UDHzzynr+M4xVlVmzxmXOELA SXuQsVjD0lcO/cJmoAnJU+Y+GQJP/Qg2I/nkDryytXGQMG2msPORGeHjyc5yar70v6sY +8rTvuU5WI0/0VCM2JcHtEirAfL9BiIyamkXri96v8XOcFiTLiVTtVfL3p/qYXliuUkG jPow== 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 u12si590358wrf.205.2017.12.06.15.09.37; Wed, 06 Dec 2017 15:09:38 -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; 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 14A2F6808B8; Thu, 7 Dec 2017 01:09:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-2.mx.upcmail.net (vie01a-qmta-pe02-2.mx.upcmail.net [62.179.121.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E2C356808B8 for ; Thu, 7 Dec 2017 01:09:23 +0200 (EET) Received: from [172.31.218.34] (helo=vie01a-dmta-pe02-1.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eMioj-0006nH-5I for ffmpeg-devel@ffmpeg.org; Thu, 07 Dec 2017 00:09:29 +0100 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eMiod-0000D6-2K for ffmpeg-devel@ffmpeg.org; Thu, 07 Dec 2017 00:09:23 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id in9H1w0160S5wYM01n9JwA; Thu, 07 Dec 2017 00:09:19 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 7 Dec 2017 00:09:17 +0100 Message-Id: <20171206230917.17046-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.15.1 Subject: [FFmpeg-devel] [PATCH] avcodec/vp9_superframe_split_bsf: Fix integer overflow in frame_size/total_size checks 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes: signed integer overflow: -1698586465 + -551542752 cannot be represented in type 'int' Fixes: 4490/clusterfuzz-testcase-minimized-5210014592532480 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/vp9_superframe_split_bsf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vp9_superframe_split_bsf.c b/libavcodec/vp9_superframe_split_bsf.c index 6d6d8e664d..0d2523ebf7 100644 --- a/libavcodec/vp9_superframe_split_bsf.c +++ b/libavcodec/vp9_superframe_split_bsf.c @@ -59,7 +59,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) if (in->size >= idx_size && in->data[in->size - idx_size] == marker) { GetByteContext bc; - int total_size = 0; + int64_t total_size = 0; bytestream2_init(&bc, in->data + in->size + 1 - idx_size, nb_frames * length_size); @@ -70,7 +70,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) frame_size |= bytestream2_get_byte(&bc) << (j * 8); total_size += frame_size; - if (total_size > in->size - idx_size) { + if (frame_size < 0 || total_size > in->size - idx_size) { av_log(ctx, AV_LOG_ERROR, "Invalid frame size in a superframe: %d\n", frame_size); ret = AVERROR(EINVAL);