From patchwork Tue Oct 9 03:14:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 10613 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:ab0:73d2:0:0:0:0:0 with SMTP id m18csp4373325uaq; Mon, 8 Oct 2018 20:17:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV60VKU3qBB4/UOXo14c2GpNaLYVBJnJlFNjs/L9TzA7xV86p/apY4l8nR4uT6EBDzuMDfsEe X-Received: by 2002:a1c:5e07:: with SMTP id s7-v6mr367370wmb.91.1539055074938; Mon, 08 Oct 2018 20:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539055074; cv=none; d=google.com; s=arc-20160816; b=aAyWzn9nwy2zcU+EFCbCOTzhRfy/UOLDd8UzQE2S6zNR9H/Hb7HTst0BJeK8jWYT+d suwCGlh776Zk4ohitYZ8sLbwAtWXEfGmua+4wcsxA/Z4yieBB8ppc7YQFRlDmrYGIsSd Wyy3Scxppswi0dzchgOz6VaAfmoa5gJDoWYGBB2ec38/V2EV1cotBbGnPfDAH6noJEDb NTozVuQoTxwnHyvJIv49CpPdb5F468uPl7+Y0t7JrNdqGgfBwVmMbdO2adK0e8yn011m rxqnMb/F0P9PXbhJQSDafPDkwiDP7CMsyJkJEJPyy6/7blPhNRiFBDiQRma+iHNo+FSv y4kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=03EUSysj0SXWtBFvIueFiUb11hB7xoKGhOOqA5SecDM=; b=aVxmvWNIwuvocxIQprjGqugxfLq+xig3Woa9si2WWFzYIUyi7gzGy0SdfefE0WLjsR PXajhUJINSQRJT/VqWmVmo8Ty1bziQUix1uBF496r4U5KIyPctlegAhp3PqLPOIc4Cl2 DOCK/2yOxx1ml0b26WOgYa5szGVf0BfO9/wTovmFQFHL2zSp/EjYEflSAnYxJkS0z/Xr OcJ+8qwTFkicmZZCV+hfl2DjVPAyEML0qJfhz/wrofm4H/GX0FwIGN7K4D+C/JBZBc2i PuBCvpPoI4qzFyX9Fg2f7ZNEUG+cF9t9AUum2frnAsWW+DIjNFwhIXnyTWD0FptoYNK6 Pp3Q== 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 g5-v6si207939wru.308.2018.10.08.20.17.54; Mon, 08 Oct 2018 20:17:54 -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; 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 EA269689A30; Tue, 9 Oct 2018 06:17:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-1.mx.upcmail.net (vie01a-qmta-pe02-1.mx.upcmail.net [62.179.121.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BC5D06883D6 for ; Tue, 9 Oct 2018 06:17:24 +0300 (EEST) Received: from [172.31.218.49] (helo=vie01a-dmta-pe07-1.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1g9iWo-0004n4-4r for ffmpeg-devel@ffmpeg.org; Tue, 09 Oct 2018 05:17:46 +0200 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 1g9iWi-00071j-Hf for ffmpeg-devel@ffmpeg.org; Tue, 09 Oct 2018 05:17:40 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id lFHY1y00V0S5wYM01FHZ9U; Tue, 09 Oct 2018 05:17:33 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 9 Oct 2018 05:14:22 +0200 Message-Id: <20181009031422.24611-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/ffv1dec_template: Check for the end of input after 1024 pixels 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" Fixes: Timeout Fixes: 10385/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5689206987292672 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/ffv1dec_template.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c index fecdbd0025..25032feda0 100644 --- a/libavcodec/ffv1dec_template.c +++ b/libavcodec/ffv1dec_template.c @@ -50,6 +50,11 @@ static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w, for (x = 0; x < w; x++) { int diff, context, sign; + if (!(x & 1023)) { + if (is_input_end(s)) + return AVERROR_INVALIDDATA; + } + context = RENAME(get_context)(p, sample[1] + x, sample[0] + x, sample[1] + x); if (context < 0) { context = -context;