From patchwork Fri Nov 18 21:09:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39330 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp611799pzb; Fri, 18 Nov 2022 13:09:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf6LTQoSTmLeVK36prnJci3Y7h5bCx34vZW8SCd/rU3GKpjfCFXodaLKob91BJQA7xGtjaUb X-Received: by 2002:a05:6402:3810:b0:467:42a9:3568 with SMTP id es16-20020a056402381000b0046742a93568mr7581780edb.70.1668805773380; Fri, 18 Nov 2022 13:09:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668805773; cv=none; d=google.com; s=arc-20160816; b=CktsBrveAFJ+Puvuuu3P4DpBqfTV0PiQk3mQvzwzvGRbEd37hg251JbAMonTDmrWG0 rDWMBrbSUkP0/axgQ9tk/2ImREoDutvdJQr48rEuq8VEYESVYwEnOhdWs1hIXBJWhSXm KP6NSG3p6VosSGa5YNoxjqulDEr8REtiKGo3XAMkksUf9T5aBV1WaPiZOZez2mcM29ol uH4bzRfapmpZ4+DEVPRYxK6+4LztnkiIVAJMPsRp+3VIwShy2QZS6aR7oRjAmBFPocbQ g6DzNpXCRvOWUze1VG3N/W/6oBjOzHPyXAeEO1Qolwoc3iA/i8I/W+mwm3ZlpG1DOCby Wa3Q== 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; bh=LChNYWmodrfhyOIVSg8oXR8dQusSu2rPGGQtST4sAqQ=; b=Ep6OpKDXUXF1UB6cIS3XAIApQE+vraHTeOYp8MtbuBT9cEqZnBGz+A89M8k3IZ6d+z BjC2XKQ5JASZBLE6wPNZ8sA9Mptu6paMLY0Bij5UErqxhYnv6XpmLeeXFklUdQyiJbps iN13IUGO9QO2lSBgkvA3pVGzY0bnaRLv25tbL73IZpDNvuAv9Bd1TV7QqeYVrIUgVQ95 s+qwMNsFiJf3QaS9khvcTbI1N5v8cn8c+jwzNtFOq5Ut8HcCc8R3CtFFdPLhcTIKQUID lxtyj5L0+t7RX/cOXhRY9ZvmTtNSSw5Q1+nPpaDfipVpiuX5ojvaUYQZJxJGpPJMrukK 6Ptw== 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 p24-20020a056402501800b00461dc830100si3974933eda.452.2022.11.18.13.09.32; Fri, 18 Nov 2022 13:09:33 -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 9CD6F68A607; Fri, 18 Nov 2022 23:09:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6A94468AA68 for ; Fri, 18 Nov 2022 23:09:21 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 560A160007 for ; Fri, 18 Nov 2022 21:09:20 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 18 Nov 2022 22:09:15 +0100 Message-Id: <20221118210918.3169-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/tiff: Ignore tile_count 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: x+sPgWAJhNSD Fixes: out of array access Fixes: 52427/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4849108968144896 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/tiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index cde318d5e5..b962dce5a2 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -994,7 +994,7 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame, tile_count_y = (s->height + s->tile_length - 1) / s->tile_length; /* Iterate over the number of tiles */ - for (tile_idx = 0; tile_idx < s->tile_count; tile_idx++) { + for (tile_idx = 0; tile_idx < tile_count_x * tile_count_y; tile_idx++) { tile_x = tile_idx % tile_count_x; tile_y = tile_idx / tile_count_x; From patchwork Fri Nov 18 21:09:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39331 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp611887pzb; Fri, 18 Nov 2022 13:09:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf5HPJYYCFhUMVyBtZvOH9Mhw/mykmWPuqiu1G5R6i/NZbnX+Qp4V1XYViLOVVxBvopJ4Hhl X-Received: by 2002:a17:906:c405:b0:7aa:4560:2dc7 with SMTP id u5-20020a170906c40500b007aa45602dc7mr7646473ejz.33.1668805784443; Fri, 18 Nov 2022 13:09:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668805784; cv=none; d=google.com; s=arc-20160816; b=hC0MqNWNM0ry4eCYepmv6WqBaXeUH02A29rmOkVxEU1osCXNiAn+4Z09ZVVcGTG5/A jo8uWyVxCBN6Rma6HE59ZKoh743JJwvnC8lK+ZQ5dG71K3Qj5DLyVP9JlrOGk6spdnPp E3lg59Y31wtap55Bt7UXuObi1VznfYOe6LO7LwcKHTeSwYt6Lzs+RTkw5P/hpWyZ3b6b YGwjPlfo0xoPN+ccN+QT2eCOirQQzXgSw0vGV0wfIOo5MP/Ie/+HBOd2e2+YwI7tc5gy nn3062Vd0ZomU9gKyeOzczR9ski2nV2HuMUMV1ptcoi6hGthk+Y3Yl6u5ajgp1s2Qbav bXWQ== 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=T9NHZR6mau0REybyb5SHGJ7a4v1K+S+Cme+Wxy1IoOU=; b=BGGa04OigE8SkFfkttJloQtmeEoMTsNsJXci/HwUdC393Xm4XAr5oCf4beNB8F2/LG nUNpQ6+Z3qQec4i/KgOMPLYf2wTwfWViX+y/apWxbBFWW9BA3pTio3mkF3rLf8Iguueq zfxYjgR0jZXGquGMoGjYtmt/WoQMoYns8RuLC3iEpkAt5e8h/C2ifW14HxdgTE64Ygqh 3W+bA27RaA262gK8QdDiU/zw9OIoXyMJRaZBRsHZPpiRTFvH9YV5ktRU3bR6niSdbc/L C9XzD+DDGqL1pUY/zUig8UeXuMG43ksWPj0WuF6ffkQw1o1YzippprNuyInZzNxOwEBq L3rw== 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 b19-20020a056402279300b00453b9f11bb1si4194199ede.206.2022.11.18.13.09.42; Fri, 18 Nov 2022 13:09:44 -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 E147968BAC7; Fri, 18 Nov 2022 23:09:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ACB2668B5F8 for ; Fri, 18 Nov 2022 23:09:22 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id D305D240004 for ; Fri, 18 Nov 2022 21:09:21 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 18 Nov 2022 22:09:16 +0100 Message-Id: <20221118210918.3169-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221118210918.3169-1-michael@niedermayer.cc> References: <20221118210918.3169-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/4] avformat/id3v2: Check taglen in read_uslt() 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: pNsCjgLyQeNe Fixes: Timeout (read mostly the same data repeatly) Fixes: 52457/clusterfuzz-testcase-minimized-ffmpeg_dem_ALP_fuzzer-6610706313379840 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/id3v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 191a305ffb..cb31864045 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -377,10 +377,10 @@ static void read_uslt(AVFormatContext *s, AVIOContext *pb, int taglen, lang[3] = '\0'; taglen -= 3; - if (decode_str(s, pb, encoding, &descriptor, &taglen) < 0) + if (decode_str(s, pb, encoding, &descriptor, &taglen) < 0 || taglen < 0) goto error; - if (decode_str(s, pb, encoding, &text, &taglen) < 0) + if (decode_str(s, pb, encoding, &text, &taglen) < 0 || taglen < 0) goto error; // FFmpeg does not support hierarchical metadata, so concatenate the keys. From patchwork Fri Nov 18 21:09:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39332 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp611965pzb; Fri, 18 Nov 2022 13:09:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf5QN4/EC827gAS6RTF2MDeeB9/w83tf4gpKmxdD585DcCT87SaRcWPn80oEZseHjkx9A69o X-Received: by 2002:aa7:c9d0:0:b0:458:ed79:ed5 with SMTP id i16-20020aa7c9d0000000b00458ed790ed5mr7699915edt.374.1668805792143; Fri, 18 Nov 2022 13:09:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668805792; cv=none; d=google.com; s=arc-20160816; b=uASaNcGxgdy3zWKKtPIiDIQqAOjuB/6c1uSBsdB4dlZQyQO4h8gfMNvm15u0AlglVt D/IZpoPEjjS4nNeYz1PmPRVgj3QZ1XY0lK/65uvfNvf/2HE7PMz2IvUXhlX1WygfisW4 UWbnVyXCA+38a+MkdYUdOz7mHB9QE/dIPxSsKk/4P0prulbHzENgDNn1z0Kw82t2eDca TwOyYg3I4xsT1+/WfPsotff5Dtb4wjsEgLtfWpvBlSBl4qucAMkxbKIvvQ2PPI5yREEQ io3OnluWDqoUdQh8uuo3mXHxqQDX2lCSrOWM/mbiNYUCpDSP6LCtHgZ9eOJcO16qHlHx 8/MA== 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=xiKe/59EcT7gr4TpAAFeW5uEwS7w+sSJZnMIOtd/1UQ=; b=q8tcfRnWa2SiY/cNnXLwM8mRkLBKCAh+zy13mHzlJMRGQxuK6kxbjAACyZh5ZFA5Qo qwd5n39/JejxiH6fV38hvNVGpKhq4m/T7O6/zhx02mswJU7OVuKI5hOV5F3F6/vQ+1aZ 1cKflTLXk7ORpXLxHnicUk6TnVLTI0ME9y75oD07ZVHXNAgif9nMfla+VFWbUWNay8f4 XOukSaseB9Pc8jjp7dNXKYWo1e+kd3h+rb0Sc/kLibzCLAsRb8I2sF+cWUwtRHweMZ1P 3PAiz03we0kJopocX/7Ey690Is+W9oOXhU822SI4728x2e/748hGiGcPkwtGUreo+Pag dRlQ== 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 ta6-20020a1709078c0600b007ae0e8f59a6si3432040ejc.821.2022.11.18.13.09.51; Fri, 18 Nov 2022 13:09:52 -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 01B0568BAE8; Fri, 18 Nov 2022 23:09:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C146A68AA68 for ; Fri, 18 Nov 2022 23:09:23 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id DA942100005 for ; Fri, 18 Nov 2022 21:09:22 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 18 Nov 2022 22:09:17 +0100 Message-Id: <20221118210918.3169-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221118210918.3169-1-michael@niedermayer.cc> References: <20221118210918.3169-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/4] avcodec/mobiclip: Check input size before (re)allocation 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: iQOrTRn2nrQc Fixes: Timeout Fixes: 52566/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOBICLIP_fuzzer-4913160050311168 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mobiclip.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index aca462428c..c3b2383dbc 100644 --- a/libavcodec/mobiclip.c +++ b/libavcodec/mobiclip.c @@ -1216,6 +1216,9 @@ static int mobiclip_decode(AVCodecContext *avctx, AVFrame *rframe, AVFrame *frame = s->pic[s->current_pic]; int ret; + if (avctx->height/16 * (avctx->width/16) * 2 > 8LL*FFALIGN(pkt->size, 2)) + return AVERROR_INVALIDDATA; + av_fast_padded_malloc(&s->bitstream, &s->bitstream_size, pkt->size); From patchwork Fri Nov 18 21:09:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39333 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp612037pzb; Fri, 18 Nov 2022 13:10:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf7vlIgdOgsDVHJMm8rbczpGX38evzLuMRpqdfrHBYrRF8pywUMCID3k/mhRxtToTlDfOxGc X-Received: by 2002:a05:6402:114c:b0:457:35d4:ac66 with SMTP id g12-20020a056402114c00b0045735d4ac66mr7616114edw.415.1668805801211; Fri, 18 Nov 2022 13:10:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668805801; cv=none; d=google.com; s=arc-20160816; b=sRtfBrO6pOoGeXvoKDFZcxte5iIx79Kv1YKk9UQW+DZ2OiwZ1yx7zF02Ffk82mgYqU lB6FPCwPqN4ybz1BUkQJ7+3EII67GvxbsK8UPwhpF8c89hwmPAox/E7aHMKOGbNrwgND Mr6tmBQKKcx4naKJj8IbYL7wvQbfqZ+EA1mzSJB9O6gJ2BW1Ufiiw/XdwNqloh0hWCgq oD1M4JP3d92TV1K+MGF9ECWEGU6eRDLwHV+h84lTaD8Y8xzZT+vCqC6I6oUckZZgJK+m cwoTr9QDIGTjP8jN0o3+UwxEo5sXrKxlQ3CeBvqoB0qq5oV4XmKGENlqYceETG6clDs9 xUHA== 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=3kvYWkGScOvK9ThUW4m3/SVHgrsgQ3YhbxOujjPP4m0=; b=H7Gtc5EyDelUabiU3Hi0bbZ3y5jAM2geZXnXMoJ8BDMK/Dpcgl7ok54qwjLdBIXql8 4zI5VJYoa0x8VC7w8w56Mei38s4XUWEvQ+d9O4+DrrvlfNez+als/r9d/NuDMEf2JwEG Tq9rl+geHQySdwDnozAn9Qo3LeO1j44TA7PBIR0cMUF0HS3FtWR5t2XtVgLd8jJVLDBq OOauPbRSLtdJtRGLS2NlTjvRGBHjw+ZL4yakk0kIL7LvXa82jMnSjYPfH8xRc58L9cke NtE/r1BFMFr0tYclVXf+hPUTfJd/tGoBz0JLJci9b8xZpypjqKcV2egUdANSqmYHvzMW WMIw== 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 rl24-20020a170907217800b00770d9e664f8si3165464ejb.152.2022.11.18.13.10.00; Fri, 18 Nov 2022 13:10:01 -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 EFD9E68BB52; Fri, 18 Nov 2022 23:09:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C352D68B7BA for ; Fri, 18 Nov 2022 23:09:24 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id E82C4FF80B for ; Fri, 18 Nov 2022 21:09:23 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 18 Nov 2022 22:09:18 +0100 Message-Id: <20221118210918.3169-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221118210918.3169-1-michael@niedermayer.cc> References: <20221118210918.3169-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 4/4] avcodec/vqcdec: Check for end of input in decode_vectors() 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: 6OAqXzM55btu Fixes: Timeout Fixes: 52695/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VQC_fuzzer-4882310386548736 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/vqcdec.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavcodec/vqcdec.c b/libavcodec/vqcdec.c index 5d1a03158c..18cd99462e 100644 --- a/libavcodec/vqcdec.c +++ b/libavcodec/vqcdec.c @@ -137,7 +137,7 @@ static void seed_codebooks(VqcContext * s, const int * seed) } } -static void decode_vectors(VqcContext * s, const uint8_t * buf, int size, int width, int height) +static int decode_vectors(VqcContext * s, const uint8_t * buf, int size, int width, int height) { GetBitContext gb; uint8_t * vectors = s->vectors; @@ -155,9 +155,11 @@ static void decode_vectors(VqcContext * s, const uint8_t * buf, int size, int wi *dst++ = get_bits(&gb, 8); while (show_bits(&gb, 2) != 2) { - if (dst >= vectors_end - 1) - return; + return 0; + + if (get_bits_left(&gb) < 4) + return AVERROR_INVALIDDATA; if (!show_bits(&gb, 4)) { *dst++ = 0; @@ -182,6 +184,8 @@ static void decode_vectors(VqcContext * s, const uint8_t * buf, int size, int wi skip_bits(&gb, 2); vectors += 32; } + + return 0; } static void load_coeffs(VqcContext * s, const uint8_t * v, int width, int coeff_width) @@ -392,7 +396,9 @@ static int vqc_decode_frame(AVCodecContext *avctx, AVFrame * rframe, avpriv_request_sample(avctx, "gamma=0x%x, contrast=0x%x\n", gamma, contrast); seed_codebooks(s, seed); - decode_vectors(s, buf + 7, avpkt->size - 7, avctx->width, avctx->height); + ret = decode_vectors(s, buf + 7, avpkt->size - 7, avctx->width, avctx->height); + if (ret < 0) + return ret; decode_frame(s, avctx->width, avctx->height); if ((ret = av_frame_ref(rframe, s->frame)) < 0)