From patchwork Fri Dec 15 18:45:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 6798 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp855933jah; Fri, 15 Dec 2017 10:45:55 -0800 (PST) X-Google-Smtp-Source: ACJfBotbroAdGfiXlvjO1bdcBaKvDVpcoSTSJA1hJYgQJzC9dMKNKSjtpcBCIKzXjX3eSr2OZU5d X-Received: by 10.28.183.132 with SMTP id h126mr6507131wmf.76.1513363555862; Fri, 15 Dec 2017 10:45:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513363555; cv=none; d=google.com; s=arc-20160816; b=TWQHWl73R2mi5D6H9hUFGCMbFHpychANIIt4XCLQsiBWujwXEiDmctnx1a+7v5+zU0 tsTyWpzmGrUq/SxEfkiCLHxWDKjc4TQFCcbQMb+z8ZFtARbaZVNui7KsUPInfP5u3Wo1 9b8xo8B0dc/dc5tSsdNpiWALJmXKZqcxgU3ZGVMFTWJ0TZYwcKqSKveujovyD+nkVGTU 2e4/GbxeLkGZoZ5nSMqDCAPkigDNoKc201egNMBfjGPDmxHFGQx0LeddvqmRwnB0+7h0 wvPA2xBrQAIIucYf1N56NU5Wro3oHCbrcZDq9zc0+Hi/rkF5pb0GdLmKbrObM65Ui5+3 4+pQ== 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:arc-authentication-results; bh=0N9UaoZ+Dg0QpqGq1HYXtH6Y1aDei4nMzpF/MoMs6lE=; b=OguCowcvb+iAex0VNx+PcdSR9CuKeSz578AfsokWGbmmDD05GopBuKH/ubUjlI1scz le/+HUwbLZnEh86M5GPybPL/tyCMgqtTY9zdIGHporYWonUKe5mNc0K9I6L3bDdg3p0P 8kc7qvyy5cICA+45N9n97paiH0ZZdXCW5pMesXyLDKjM8GpSgz/Fbobni85SbllvUE5B I2SoOAhpBUarlJO4gKDmXnRVzfpPf34/jzvx37mEKdlP3vUHG2XqcTLchoZu4FWiyCVl qA7xdmiBpz/3TCQOPYVQOVZSo67IXG3QhBBg1pJrRY0RyR9+xGzXaYx7AhCp4E5YAjgE 3QRw== 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 o103si6029148wrc.2.2017.12.15.10.45.55; Fri, 15 Dec 2017 10:45:55 -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 258D8689A95; Fri, 15 Dec 2017 20:45:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-2.mx.upcmail.net (vie01a-qmta-pe01-2.mx.upcmail.net [62.179.121.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 810CC689A2A for ; Fri, 15 Dec 2017 20:45:25 +0200 (EET) Received: from [172.31.218.50] (helo=vie01a-dmta-pe07-2.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1ePuzG-0000lQ-D6 for ffmpeg-devel@ffmpeg.org; Fri, 15 Dec 2017 19:45:34 +0100 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe07.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1ePuzA-0002kb-VM for ffmpeg-devel@ffmpeg.org; Fri, 15 Dec 2017 19:45:28 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id mJlN1w02X0S5wYM01JlPvL; Fri, 15 Dec 2017 19:45:23 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 15 Dec 2017 19:45:20 +0100 Message-Id: <20171215184521.822-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171215184521.822-1-michael@niedermayer.cc> References: <20171215184521.822-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/hevc_sei: Fix integer overflows in decode_nal_sei_message() 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: 2147483520 + 255 cannot be represented in type 'int' Fixes: 4554/clusterfuzz-testcase-minimized-4843714515042304 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/hevc_sei.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index 8dd975508a..c59bd4321e 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -324,11 +324,15 @@ static int decode_nal_sei_message(GetBitContext *gb, void *logctx, HEVCSEI *s, av_log(logctx, AV_LOG_DEBUG, "Decoding SEI\n"); while (byte == 0xFF) { + if (get_bits_left(gb) < 16 || payload_type > INT_MAX - 255) + return AVERROR_INVALIDDATA; byte = get_bits(gb, 8); payload_type += byte; } byte = 0xFF; while (byte == 0xFF) { + if (get_bits_left(gb) < 8 + 8LL*payload_size) + return AVERROR_INVALIDDATA; byte = get_bits(gb, 8); payload_size += byte; }