From patchwork Wed Oct 4 22:59:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44155 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6384:b0:15d:8365:d4b8 with SMTP id m4csp31252pzg; Wed, 4 Oct 2023 15:59:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUsGk1tg7UJOIau24LqT+X08cYMKKttEnU3Y8GPoXgdgCqsnqRtwN9EXUmpWGL/YNoDgNi X-Received: by 2002:a50:fc11:0:b0:52a:250e:a052 with SMTP id i17-20020a50fc11000000b0052a250ea052mr3314367edr.7.1696460374877; Wed, 04 Oct 2023 15:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696460374; cv=none; d=google.com; s=arc-20160816; b=RMoBweA+MXK4198c9e/EgwRHPPCH1RqRYGGQ/kQ0cSZe2JY8JAh8ezrAilAsF+yW8D DuF5w0KHdzj6Cu7P6xgQyy+pSaIekc0nhuq2sD8vvB9zvhXLDBwDbUnkir9BGaC2dT+P yPedjFNm9FZx8hrGgj89ybvu2k7z9ZJfgc1vRZgZlgkIbeMvbd0CJXYhF4fIXtyE32Qm PwmW9VyLBIuDtVYNRw/ZcIsiSe6+CM5TxXbdT2v3lkDPX7wSSXDA8bUuxMwmuOkQgpGr 96eCurnDngyh39qUOzCMA5llBJM1aO0bIgsrld9RPk2Rvn5mjR6UO4DYQIN39enAgHxN 8y4w== 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=8uprkJwFWmYADtKV4MUyhtkh0D87LjUST8W/HLrywZc=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=YjQ3CLiPG6a5vWYP4MOc7+E5ApQKPlejFp7+tMHkRJjlqxnNwNgZYzJlZVrtyggeJa Ndf+sg3exjnVrRZnaHFweNMW82ykOo6wKbu8jK3UBnyC2kn9B/NQP8Z3jczeOEU4KaL4 S6mX2xaZDZm3M80HTyU5PjKhbx6FzNFWivNQA17trS7v6Fu+bUZhvHjwiCLJtSF++FHQ SocwFcG0keIDwd5PRYCa6K3tV0dFoAZRN3nCMkPm0tO4KI88L2NFd/iq7Hux+Q+f7QDw dodAYZSN9SQKI9u1MR+bQqAaW9YQtV93JTAtXj1hBd7FWQhKC8FwKB+c+fVrAxPY89EE ik6Q== 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 l15-20020a056402028f00b00536309d7b14si110034edv.516.2023.10.04.15.59.34; Wed, 04 Oct 2023 15:59:34 -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 2889568CB0D; Thu, 5 Oct 2023 01:59:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B782F68B752 for ; Thu, 5 Oct 2023 01:59:22 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0487B1BF205 for ; Wed, 4 Oct 2023 22:59:21 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 5 Oct 2023 00:59:18 +0200 Message-Id: <20231004225921.30287-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-Spam-Flag: yes X-Spam-Level: ************** X-GND-Spam-Score: 215 X-GND-Status: SPAM X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec: Check image offset 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: TOwiJP1/U4/6 Fixes: left shift of negative value -538967841 Fixes: 62447/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6427134337613824 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/jpeg2000dec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index eda959e558d..691cfbd8915 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -238,6 +238,11 @@ static int get_siz(Jpeg2000DecoderContext *s) return AVERROR_INVALIDDATA; } + if (s->image_offset_x >= s->width || s->image_offset_y >= s->height) { + av_log(s->avctx, AV_LOG_ERROR, "image offsets outside image"); + return AVERROR_INVALIDDATA; + } + if (s->reduction_factor && (s->image_offset_x || s->image_offset_y) ){ av_log(s->avctx, AV_LOG_ERROR, "reduction factor with image offsets is not fully implemented"); return AVERROR_PATCHWELCOME; From patchwork Wed Oct 4 22:59:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44156 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6384:b0:15d:8365:d4b8 with SMTP id m4csp31306pzg; Wed, 4 Oct 2023 15:59:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIX3vDQ3L7yHiOwLsQlV/hxPkHqkrdHKN6ICGishO+ojq/bA2IakU7anHUjJIQr9ybC6BR X-Received: by 2002:a05:6402:14c7:b0:51d:f5bd:5a88 with SMTP id f7-20020a05640214c700b0051df5bd5a88mr3229818edx.38.1696460384647; Wed, 04 Oct 2023 15:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696460384; cv=none; d=google.com; s=arc-20160816; b=x5JrznYVbpWH26yum6Nh0N00ZNraH+Frkh6iexk0fiyFPfzXV3IDPVhchoI2Y1SAoz +kY/6TJcWyXzQ2I+frP1YxJoi9z2n1YtYZxe09R2ULp3keZ6pfVmn+3oRPMAzwZLMlF0 LSUMWHIRq4uo/PHTv1GTtHaYLDMVUH2wF76gngwuGiqOiSdZZ8epoB0mw5kgXjhy+2QA zsd53rK9vhbVZ0/eCjSeKdskKKlvCrLDdSxMdPJsPkHoBE+hWnFbOmdU0zkqRAgaGwHp EukcYOhr0+LIXJ47wAmbu/e917tO4tK5KoOhdZ1tyR7V1+h8SM6a7bAhATwXRQ7zhNz5 4veQ== 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=4MVfIKtgCTcW2pDjywnpdtfxNhlrEsV5rNdQ67mE5mc=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=RwRB0vraWcM8CQ1Hrt6xjzqZLplE1HwNPTA7bGoySaK/uwmtreef4ibZ/9B0wzNqed 0LXOad77cy8oFAKo4IBs0afiZh2Fnb9WpDgI1s8zuAH2+z9cilrWUnrOURACpaPTuseq MTgTTEFGEcHMXvcMIpL78NwIFJDMdzikI7RcOBib9JbEpZYq/VH7f6xqJXmUxXfvGeCp 3dp335yYTS0mU7cUflH/+C77mwU9FLI7NaiCmgTxPKNXdR0tdvkXtW57eNHihDRZScid lMMmZG4PTn/UYzaBK3YOy9IY6UIUVT4hOsszW9QS6t7s/a8GN/dp/ZHhWjM1P63LPEFw XZzw== 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 m10-20020aa7d34a000000b005364bc0e5c3si106757edr.124.2023.10.04.15.59.44; Wed, 04 Oct 2023 15:59:44 -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 2DD4168CAD4; Thu, 5 Oct 2023 01:59:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3279068B752 for ; Thu, 5 Oct 2023 01:59:24 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 22E5BE0006 for ; Wed, 4 Oct 2023 22:59:22 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 5 Oct 2023 00:59:19 +0200 Message-Id: <20231004225921.30287-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231004225921.30287-1-michael@niedermayer.cc> References: <20231004225921.30287-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/evc_parse: Check num_remaining_tiles_in_slice_minus1 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: 9k9wiZt1KyMo Fixes: out of array access Fixes: 62467/clusterfuzz-testcase-minimized-ffmpeg_BSF_EVC_FRAME_MERGE_fuzzer-6092990982258688 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/evc_parse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c index bd3a4416f2d..5ab33166cf3 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -58,8 +58,12 @@ int ff_evc_parse_slice_header(GetBitContext *gb, EVCParserSliceHeader *sh, if (!sh->arbitrary_slice_flag) sh->last_tile_id = get_bits(gb, pps->tile_id_len_minus1 + 1); else { - sh->num_remaining_tiles_in_slice_minus1 = get_ue_golomb_long(gb); - num_tiles_in_slice = sh->num_remaining_tiles_in_slice_minus1 + 2; + unsigned num_remaining_tiles_in_slice_minus1 = get_ue_golomb_long(gb); + if (num_remaining_tiles_in_slice_minus1 > EVC_MAX_TILE_ROWS * EVC_MAX_TILE_COLUMNS - 2) + return AVERROR_INVALIDDATA; + + num_tiles_in_slice = num_remaining_tiles_in_slice_minus1 + 2; + sh->num_remaining_tiles_in_slice_minus1 = num_remaining_tiles_in_slice_minus1; for (int i = 0; i < num_tiles_in_slice - 1; ++i) sh->delta_tile_id_minus1[i] = get_ue_golomb_long(gb); } From patchwork Wed Oct 4 22:59:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44157 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6384:b0:15d:8365:d4b8 with SMTP id m4csp31373pzg; Wed, 4 Oct 2023 15:59:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaNnrvhJ/SAxowqXYVOUOm1Qkb6uWzDJuupHgleqkCKzzVuchE4Ctv7tiMFTdfggWrbezU X-Received: by 2002:a05:6402:510c:b0:530:8fdb:39c8 with SMTP id m12-20020a056402510c00b005308fdb39c8mr899873edd.15.1696460394374; Wed, 04 Oct 2023 15:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696460394; cv=none; d=google.com; s=arc-20160816; b=QvBWoS4bhEb0Bg9DnfrfbN/WGfMubYIkQZuOevEv4GBE5HwWxLA7IFWNd3HAuiX03Y pzrTEUj535D9HGjIDD7n+EuFL81hWTLZ/WJDqQIcgXlODeHQjG4DR3a7WnbgrccIWVXf kLAIm+kuGMzg9ncRwoanvvj+oQg352P+d7KXCa4d8lCILjzriag1w6P08LMGSwHHayVe C3resvaa8/7NDIKsadDBX82dqv6Az0AfcilhxPG/EoasKJcvNIneL0RrYSeu5O5jYTSL cDgF5iH19VTauEAkIu5esq6qGaFmmryBcxoxXQkkMkj0V9EZr8KVnPxbgGKDIXoPGMXA ElxA== 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=4NmhyknjZVysortXlD3Rm2wRGBPCOD5PwxvEVXv+Wt0=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=fezybMCz4Mv5K0E0wA2ghYElGRahA2+ZAreJ7tIE4tdnYWSDBOsd+lPEpQaZ3ix5v7 3u1OH2AADJYK/Po8oBIjeLVzTu4tzECJg8fZEhsrNr4MdLkE4JQ4wbloxGBjOlyQ488E pmwnZj6N6sKLDMlevWod8TyD8MHUNdePBwvLz1peHte8UjC+P9MJjjT69vglTOFjRCfP X4a2D+YxbjgYgz8UTZO/RkWtlsUcICFERmKij628cxkzAeyPD9FS7xDHXRcwr6tthcbd M5/YlgxC8q8bluLDCxIk6Uo9CRBhGSwIcg8qSK+Qm4tieeAnAlRtpnbW64o/IoQGCSsJ mUhg== 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 u22-20020a056402065600b005343f03b7aesi112718edx.91.2023.10.04.15.59.54; Wed, 04 Oct 2023 15:59: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 1055268CBC9; Thu, 5 Oct 2023 01:59:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 13FD668CAF4 for ; Thu, 5 Oct 2023 01:59:25 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4B868C0004 for ; Wed, 4 Oct 2023 22:59:23 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 5 Oct 2023 00:59:20 +0200 Message-Id: <20231004225921.30287-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231004225921.30287-1-michael@niedermayer.cc> References: <20231004225921.30287-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 3/4] avcodec/evc_parse: remove pow() and log2() 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: d1ibzU+O1FVu The use of float based functions is both unneeded and wrong due to unpredictable rounding Signed-off-by: Michael Niedermayer --- libavcodec/evc_parse.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c index 5ab33166cf3..20b6849041a 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -176,7 +176,8 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, poc->PicOrderCntVal = 0; poc->DocOffset = -1; } else { - int SubGopLength = (int)pow(2.0, sps->log2_sub_gop_length); + int SubGopLength = 1 << sps->log2_sub_gop_length; + if (tid == 0) { poc->PicOrderCntVal = poc->prevPicOrderCntVal + SubGopLength; poc->DocOffset = 0; @@ -191,15 +192,16 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, poc->prevPicOrderCntVal += SubGopLength; ExpectedTemporalId = 0; } else - ExpectedTemporalId = 1 + (int)log2(poc->DocOffset); + ExpectedTemporalId = 1 + av_log2(poc->DocOffset); + while (tid != ExpectedTemporalId) { poc->DocOffset = (poc->DocOffset + 1) % SubGopLength; if (poc->DocOffset == 0) ExpectedTemporalId = 0; else - ExpectedTemporalId = 1 + (int)log2(poc->DocOffset); + ExpectedTemporalId = 1 + av_log2(poc->DocOffset); } - PocOffset = (int)(SubGopLength * ((2.0 * poc->DocOffset + 1) / (int)pow(2.0, tid) - 2)); + PocOffset = (int)(SubGopLength * ((2.0 * poc->DocOffset + 1) / (1 << tid) - 2)); poc->PicOrderCntVal = poc->prevPicOrderCntVal + PocOffset; } } From patchwork Wed Oct 4 22:59:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44158 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6384:b0:15d:8365:d4b8 with SMTP id m4csp31451pzg; Wed, 4 Oct 2023 16:00:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGABDn2eSIDfimduTynILE2dU06gaBh1G570MWAWGVjMC7PRSyusRlzdVkLO/guooJVScKI X-Received: by 2002:a5d:654e:0:b0:31d:db92:31ae with SMTP id z14-20020a5d654e000000b0031ddb9231aemr3424348wrv.44.1696460404220; Wed, 04 Oct 2023 16:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696460404; cv=none; d=google.com; s=arc-20160816; b=cdr53iEG7StduBnrAk/ouUSN8J0FiqMFOMLoTvVFeEcvQEAVvz2n1AxSVqzB0e5LA/ 4HmMjI/Tn6TSmOowgLlj6/BorC13C8hABy86yNuRLGitdrFT5auxZzcM2QfIkKz3sbBJ WTqR4sQDK4ORZQHS3SIQvRQCnzmeq6EDBnHNQNjU7J61DbUoxK/8w1kcNu7bXee0p5bM 2YGKG0VIzYwUjhSMqOKa+mFJ8IsVSY0s2bplrV1zxXbsHl9wvBGmuNPBQ2E/uLv+l0av kBn+Y96Bl2z/g7GGV905kW3G1sdeHxxYdd6F+UQ14y1juT8cAABwA1PrBSUPN5CnDI3J +vqg== 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=Fkabplv1w/Q8SkvTTQw1StBZVLlO+avtRgDUpa9m0FQ=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=kmuyu2VS1cWyGx8lBq3NNQAeMWU9GHwgj2uJJ93Kq7bkH+5EQqrJf6aVyBnGNlgRAT z3DT7FTRPoaL1v0t4hfrZJV/sJqTrdlKmeiO5l8atUD0im0Jqt83jKggd7bzoWjWLiTc 4fvhwgK09sIqbsvrhdlfnflHL8/a3iHrKbC8knJNV5aeDXv3wfr7feHCDTCGBTCd53BT XLgIP/YArqu9W/WpHIOaHy+e4QGbEdG9egiv8BadV0khTLXtpWXv+wI2MnOp+J4xWu7u W5h3wPInzW1neE0MlKz8h1JHCt8yCNoR4Nwi4J//CLsccFNMJOGBgY5dLehWGbuq060b scaQ== 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 f13-20020a170906138d00b009b28c286b38si73842ejc.789.2023.10.04.16.00.03; Wed, 04 Oct 2023 16:00:04 -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 E657668CBE4; Thu, 5 Oct 2023 01:59:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C0D1768CAD4 for ; Thu, 5 Oct 2023 01:59:25 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 27CBFE0004 for ; Wed, 4 Oct 2023 22:59:24 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 5 Oct 2023 00:59:21 +0200 Message-Id: <20231004225921.30287-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231004225921.30287-1-michael@niedermayer.cc> References: <20231004225921.30287-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 4/4] avcodec/evc_parse: Check tid 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: S0UhyKcxeDdh The check is based on not infinite looping. It is likely a more strict check can be done Fixes: Infinite loop Fixes: 62473/clusterfuzz-testcase-minimized-ffmpeg_BSF_EVC_FRAME_MERGE_fuzzer-5719883750703104 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/evc_parse.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c index 20b6849041a..8c0ef16f3ad 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -178,6 +178,9 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, } else { int SubGopLength = 1 << sps->log2_sub_gop_length; + if (tid > 1 + av_log2(SubGopLength - 1)) + return AVERROR_INVALIDDATA; + if (tid == 0) { poc->PicOrderCntVal = poc->prevPicOrderCntVal + SubGopLength; poc->DocOffset = 0;