From patchwork Fri Jan 13 00:01:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39991 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bb05:b0:b6:a58c:cef with SMTP id fc5csp62600pzb; Thu, 12 Jan 2023 16:02:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXvUiZV/f0Lef/qTsJBiAdllNn1eoCHkE2/FW5PF2LQnasmz2/RKT5o2bFnnV7zbnO9xDE46 X-Received: by 2002:a17:907:8a24:b0:846:95f9:5b4d with SMTP id sc36-20020a1709078a2400b0084695f95b4dmr87613471ejc.42.1673568129788; Thu, 12 Jan 2023 16:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673568129; cv=none; d=google.com; s=arc-20160816; b=Jyn8K04eIdYBjvqAfyYwEBlOXjcpzD4rd+wudPXemXGvoDL5yFpbTl6v/Ne70r9IZQ 3szsOXOzRrmEXLlKJaQA3RglhigI37gmjOLrtvf/UyRjtnBhTlEJppFecGGowcP9ky+k AI0SqfjU5JBMlc1Y6HRTsQ3dn8ZOSiLOWTgGr4KpZ0ON+9bExtm6yQ2ywCEATvY+p2qc HzVfQoLAeL+Sz4Pdl1MDC9AXcxYRIU9cE3/5LcW0rBdJ3r+NUICEFw2GfZ5RjHw7TuLz S3lOTVfce82fyomuJ4scMmyeLIlPgMzoL7bQeIViMFt9Z1KyoPor8yoS41hpwjDm1ey/ 8UHA== 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=lPa3SzdCgdGbEB2jIlKKiWK34xY5fRagseoJn3cXru8=; b=ECUaSqa5LimEouLpppldZTd25/S2Ds/nBv/9penoNbbIXlDulUMEvFXOUPwYhFDGLa DH5Fl6p5/VqiBa/kHwELuwFOLTfJySRliz2NGHcGHCJoWnccjTjMuQlihnoPnyQqTHaq ROU8AhG+ZpR9UwCI8LbHuCiVYmnHDBXX8OWdD0ABnrmsQq+fa2WFDyYAjhozdtr56twp 2yU6jphQdR47Yev+Big6ANLfmzWBmGRfT+5J4tgDY7rnYYhlx3C5lprosmmRY+FxCngq ydG7vkPb5Z2A4otfDesYmghnlcagew0HFeVIV6dClFnLjQ24KEp4SrMNvK/7QHP96OWa QdgQ== 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 mp14-20020a1709071b0e00b0084d452da656si15258850ejc.577.2023.01.12.16.02.03; Thu, 12 Jan 2023 16:02:09 -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 6AEF768BC88; Fri, 13 Jan 2023 02:01:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A6F4687F61 for ; Fri, 13 Jan 2023 02:01:41 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 60A11240004 for ; Fri, 13 Jan 2023 00:01:40 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 13 Jan 2023 01:01:35 +0100 Message-Id: <20230113000138.9994-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230113000138.9994-1-michael@niedermayer.cc> References: <20230113000138.9994-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/xpmdec: Check size before allocation to avoid truncation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: C7nr31+j7Lby Fixes:OOM Fixes:out of array access (no testcase) Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XPM_fuzzer-6573323838685184 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/xpmdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index ff1f51dd32..504cc47d8f 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -356,6 +356,9 @@ static int xpm_decode_frame(AVCodecContext *avctx, AVFrame *p, size *= 4; + if (size > SIZE_MAX) + return AVERROR(ENOMEM); + ptr += mod_strcspn(ptr, ",") + 1; if (end - ptr < 1) return AVERROR_INVALIDDATA;