From patchwork Thu Sep 13 02:24:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 10310 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp92428jap; Wed, 12 Sep 2018 19:25:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaR8bVW3MzT6KWIe/J97fQ3xRc13VD65Lr3CuYj6WkCTH/8UB9PBTQ9EVZSetdGCnLq6Y3f X-Received: by 2002:adf:f84b:: with SMTP id d11-v6mr3565536wrq.172.1536805541074; Wed, 12 Sep 2018 19:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536805541; cv=none; d=google.com; s=arc-20160816; b=CqG8ha1eYz3dKQkPCCM8juor+eA+pBMC47cvt4kItGa2iFHxQ3hF3KYeBb0usc+Syn tUJ2jGrteteN9/4ObnjtUzbubtmTgeQ12P8hYu2GDv0VoOehGht+zJUgjWFvZo4UiWHA T0/o2aI8OXp0WmAdH3PVr+dVvCuXHnBZ+/gmZ0PlTlJziCzdNQJjo5KySCMiEmBnETHo MpBdAHtkw7YXhZerM314/4uJYtR7fJQjFjyHFf63gdR9MvQf6v4WgVpX1HuDX4m9qo6t oMJ6MiCdYtlRdR34FQ4n9EnZ0gCXmrZu+Zc1P563ETivqadObxw+alCDP7d/w6RiqnOj igPA== 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; bh=N4x2V/aTjkMMnbCQ7N5DmU2Cll8kWqYwA19b7kv2t4Y=; b=IC2UHvC7B882+MjWO+gUeMB1pBN7s5fdyTyzs8AYTtbGf4vN+Fq7Squlgoh9bG6hHR wlx0GY2amd1+pGqzT7lobEdztq3t08lZcEKLFa3Veg4F38l4mmWWh50Y4EpxSMqB2Zpe utBbSuRp/jVEDgF+aZe2a45di+HNISMUGzZDv6gzp4maOXgOT/9JPZ98ZXUiSyHy/Wa3 A5j7ML9qAK9A3JjL5HMDnWYqePhbzPfvkwSN0vq10lfxjFF59tzxdQ+yFdA0IWY5M/vH esunISOGzHAefG0RGXhZ0eccUEIWg6fjky0TWbM7WIAsGHMWoXW4iL+CQcyR4c7d11n2 BTtg== 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 s84-v6si2424501wms.80.2018.09.12.19.25.40; Wed, 12 Sep 2018 19:25:41 -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 2EE8B68A56B; Thu, 13 Sep 2018 05:25:28 +0300 (EEST) 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 8E0C66802DB for ; Thu, 13 Sep 2018 05:25:21 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1g0HJz-0006MQ-EP for ffmpeg-devel@ffmpeg.org; Thu, 13 Sep 2018 04:25:31 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id aqRT1y00L0S5wYM01qRUQr; Thu, 13 Sep 2018 04:25:28 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 13 Sep 2018 04:24:50 +0200 Message-Id: <20180913022450.19376-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180913022450.19376-1-michael@niedermayer.cc> References: <20180913022450.19376-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/dvdsubdec: Sanity check len in decode_rle() 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: Timeout Fixes: 9778/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVDSUB_fuzzer-5186007132536832 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/dvdsubdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 13d52c8c68..632a53adab 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -125,6 +125,8 @@ static int decode_rle(uint8_t *bitmap, int linesize, int w, int h, uint8_t used_ len = decode_run_8bit(&gb, &color); else len = decode_run_2bit(&gb, &color); + if (len != INT_MAX && len > w - x) + return AVERROR_INVALIDDATA; len = FFMIN(len, w - x); memset(d + x, color, len); used_color[color] = 1;