From patchwork Thu May 16 23:19:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 48937 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp2546876pzb; Thu, 16 May 2024 16:19:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXgFez8VSTMU40XzUg/nLTGrxQk1ACB/lmoXKflUJ/cRbAad9dfndISZfoO7FCnQSvnos+QamlG0wVcY3Gbw/WfDSmZfIPPAcKbWg== X-Google-Smtp-Source: AGHT+IEXpUvDziyqaVKADhkp4AjrlHi+JvuSAZTlm/MFrhQgWIMRyfF+PO38eSFA/wp2DaCY8g1F X-Received: by 2002:a17:906:4f8d:b0:a59:beb2:62cc with SMTP id a640c23a62f3a-a5a2d6668b0mr1126850066b.61.1715901584509; Thu, 16 May 2024 16:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715901584; cv=none; d=google.com; s=arc-20160816; b=Y/V96JHbjkEINtOmuZdDsTG6+AR1BH/vPWO+ebCu1WIPsSojWYdf3PHn5IvstPRtVB OSoAGCkaStNTC7Mri9bRP/rOvK3x20ervqtlJYFcenzTlFRcA5pV9z6XhzYntYaMK9RZ zmYNnmQFyPcLq+muxuK776o6wTrar7+SVOiZ3TkG1ME1cG5s5KJ9RXwhOgE0AfuBbfAJ pcmHzBv71wIp2Ij+X6DeCbTrpIRHyXLzJBR2/ZqAvl6kuigcKKiy6N+kFkhI8i71AZ64 3v0lCcplBb0FAzLq7owTUFM6IHtFkY1yM+TIy3BzlPZjAWaqVv/YXHWb7g8iz8bn4ltw iVHg== 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 :dkim-signature:delivered-to; bh=11j7dvL+uIa1x0uDLXWP54wMXrWtqC4q+m5tnKCP1ww=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=0uvavRRNRDHMl0EyVmYdmOSgeOXEbd2vMxvfsNZKPH27iapHgcbDBwVWcVDhy9ac1P Fw8qrJBh4z7FZRAxKPVGfiGRFXq+2PT/1h/9BQ72tst744sgX4EUCnh5VngEdKuFy8R7 PTltx/VGSA57TExXAKOTcz2wrSl3CnRLGTRZiURl0Ie1IW2UHas5YNZq3EXs544jjlzi eAmbpB+c6gWfOL3lRR5Oxg3TiaM1XqgIKgj2lDWIrl7Ce0RKYbFsChT6d9EywGCS4tgV 6YItCFnprv+0CR2wTlBRzVuaY9Xe6HNGWBAjsCo3h69NoFylbVM3A7gk1cOo6BJ5+bqf OPLQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=VKjAIDEz; 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 a640c23a62f3a-a5a17b22159si914862166b.487.2024.05.16.16.19.44; Thu, 16 May 2024 16:19: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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=VKjAIDEz; 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 5A0C468D293; Fri, 17 May 2024 02:19:40 +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 436EA68D011 for ; Fri, 17 May 2024 02:19:34 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 5A8D21BF203 for ; Thu, 16 May 2024 23:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1715901573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=FK/jPYkViPFVyfIOkaNiMCUzcCxnDsxodA6JLAE/B9o=; b=VKjAIDEzHqIwEi7sSIXvyVgrsyV4hTYUb4yxGKpTwWFrRPv+Pj/Mw4Fz9sDz0YFPdLDJMa 3gZEXxMaHYa2CenGgQkRWQSYvL6v+Qee7NnDGCN90AjxxWrsxq/m+BGgaFpxhl8gp0ykw8 lWp3REBAUp0GSXkrll0YnXYH86+sC9dcYqcUG3y6onitKqNmFqOOTc9LXj5gI6qoX/KuBR d6z2Wgzqr2fhtDqlwbM/l0ah2Es2pIwN8CaJv3vjT1aetwzjFXd3PGNJYgLv/DUTOWXnNK UcYPvPFN9etShXbp/t44xIML2fydFIQA7uNnQWJzc6KqLCevzUBvB0Drn8weGg== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 17 May 2024 01:19:28 +0200 Message-ID: <20240516231932.6950-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 1/5] avcodec/rv34: assert that size is not 0 in rv34_gen_vlc_ext() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: It6MkIyb1Cbd Helps: CID1548380 Uninitialized scalar variable Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavcodec/rv34.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 23a570bb807..4ce0cc58d05 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -98,6 +98,8 @@ static av_cold void rv34_gen_vlc_ext(const uint8_t *bits, int size, VLC *vlc, uint16_t cw[MAX_VLC_SIZE]; int maxbits; + av_assert0(size > 0); + for (int i = 0; i < size; i++) counts[bits[i]]++; From patchwork Thu May 16 23:19:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 48938 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp2546940pzb; Thu, 16 May 2024 16:19:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVTgnoVUJ/8CYIdu0EWjaplK1iXPhoUtwW3sF7bTbFgZpLd2TbTjWx3i1xqsoOpRp8ZtcXzvMsbt+lZHGZrgSSMQLGbd8D9nRzI4g== X-Google-Smtp-Source: AGHT+IE4769+HwKpo2VwoVbnlsDCU/PtTg1QWNADFCWe0DXpKMOD1+pQUPuiQEjk7Nj/V096qD8J X-Received: by 2002:a17:906:2510:b0:a59:a7b7:2b9e with SMTP id a640c23a62f3a-a5a2d53ae41mr1220581466b.8.1715901595594; Thu, 16 May 2024 16:19:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715901595; cv=none; d=google.com; s=arc-20160816; b=KMMkVNOf5pK6tCShv+LkDq2HLBgGM6fkuDPEfH6jYleWSAGtNI+ViaY9EOaOb2ny86 O9uN6TPAnUezNl9xvqKFYhH3tcuTAixCpdG3YrSDCqc8hNcrN1VEYZwbffdxkUaHCm16 455bvMv+EuvdmkfYJINKzpAMfI6Hx/NoaPZYDGtN4hrPE3C1dG+R35xZsbQWZkagohUM 1LfC/N9sEHlBLIQr/DrhJViUh1awLZNgfck5Nsc5e81Xwj1GAd317UEuUMeLMpQdoWSz MvSZVA+BV3zwMm7PY8CD5dZsUER2DQjY5yUPQHlm97OMHORBuTIKyzH71KEQ1T72NTJJ j29w== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=htcVc3Mb7fX3ybCBzAbc0l9PSY0iQ+RJme8jfUjH3os=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=E7Up3p4KycKGav6PRoa9tpLQvPY1G9j/3GdeSFIL/UDep0a53h/DZ4KAhrvs6bZh2B qXCANF1B4CzsKNxa7UMphnvubuKX0L4IvdP71wptSev7Phbo3LhODMEjD08nmyknp5Fu hRyxWRLtFQnssBeuLjbxfKlW2Yz6E2KqHWwViyd3pmuaH/g2COlj5ZnZXA5A8hdHbEUo akiDtv/N98vD9NGx5LDZbpvZPQkfDiiOuZfTRijp8tgJNntGMGUHCQsS56NhR1T4fAyp x6sW5i5vIlNHzJh4pzlzfIqmuPbo62yM4QJ+BQPaswv3oRfXVCU4Puae8j3Pt/dvo4+C lv8g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=M0gtES0f; 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 a640c23a62f3a-a5a86dcfdefsi332042766b.826.2024.05.16.16.19.55; Thu, 16 May 2024 16:19:55 -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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=M0gtES0f; 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 7CE5968D2AC; Fri, 17 May 2024 02:19:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D37668D283 for ; Fri, 17 May 2024 02:19:35 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 85D1A1C000C for ; Thu, 16 May 2024 23:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1715901574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DpEw8bRF0GBEQZrethXespfeIZxb6XxVqJAh8/+whVg=; b=M0gtES0frME6FXKlax9FEa3E4zQ3K4EmLFhXB8CHCKdm5Zsv9j8Mz7ddcrNChgFWZUnOAJ afDu0LC2g3c4pe5EIy0IUAd9kB8eEQlCiElqBY2pwAIQulNxaV/7huacy8NMRjnl+A8mi5 Egh9SC7h4O6bsHyYlmQwoIpz7ZWhKuByFMjoQ7QhAufj/ie0korVvLNLZWhWnSrYdDY/eJ t0+1b1p3i4AoO3tnPB5oIFY2WUKtxXkdvhNk4CsJDI8dJheWPsHLQKtr/LxC0/aYkoI8gR XT3hG3DZWGOjt3qlbl4u2q0ef+eZZn1MzQkUDWfI1qKEWWkTMdRic7y1t8p3aQ== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 17 May 2024 01:19:29 +0200 Message-ID: <20240516231932.6950-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240516231932.6950-1-michael@niedermayer.cc> References: <20240516231932.6950-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/scpr3: unify adding 127 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FOvPRr90ukWq Untested, i have no testcase nor does fate Signed-off-by: Michael Niedermayer --- libavcodec/scpr3.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c index 5271717ac79..79106ddcff8 100644 --- a/libavcodec/scpr3.c +++ b/libavcodec/scpr3.c @@ -42,7 +42,7 @@ static void renew_table3(uint32_t nsym, uint32_t *cntsum, freqs[d] = b; freqs1[d] = a; cnts[d] = c; - for (int q = a + 128 - 1 >> 7, f = (a + b - 1 >> 7) + 1; q < f; q++) + for (int q = a + 127 >> 7, f = a + b + 127 >> 7; q < f; q++) dectab[q] = d; a += b; @@ -232,7 +232,7 @@ static int update_model6_to_7(PixelModel3 *m) cnts[j] = d; } p = (e + 127) >> 7; - k = ((f + e - 1) >> 7) + 1; + k = f + e + 127 >> 7; if (k > FF_ARRAY_ELEMS(n.dectab)) return AVERROR_INVALIDDATA; for (i = 0; i < k - p; i++) @@ -688,10 +688,10 @@ static int update_model3_to_7(PixelModel3 *m, uint8_t value) n.cntsum += n.cnts[e]; n.freqs1[e] = c; g = n.freqs[e]; - f = (c + g - 1 >> 7) + 1; + f = c + g + 127 >> 7; if (f > FF_ARRAY_ELEMS(n.dectab)) return AVERROR_INVALIDDATA; - for (q = c + 128 - 1 >> 7; q < f; q++) { + for (q = c + 127 >> 7; q < f; q++) { n.dectab[q] = e; } c += g; @@ -760,7 +760,7 @@ static int decode_value3(SCPRContext *s, uint32_t max, uint32_t *cntsum, freqs1[i] = e; g = (c + 127) >> 7; c += e; - q = ((c - 1) >> 7) + 1; + q = c + 127 >> 7; if (q > g) { for (int j = 0; j < q - g; j++) dectable[j + g] = i; From patchwork Thu May 16 23:19:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 48939 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp2546997pzb; Thu, 16 May 2024 16:20:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVw/kweosgRuc2/FI8i/hRKACAbpn/PtMiohZQIbJJQAiaEy/EehlD54NSdxoizjFeS8Vr85GswIKW4P2CAV6OlLNsn8v7F/A9yDg== X-Google-Smtp-Source: AGHT+IEqIHewvouX47J1q7UR5Jf3RtLa8bWuA9kdHB9MfobnnPHuUlcZKeNBKudqbHWP3ZWyGP8P X-Received: by 2002:a05:6512:52a:b0:51f:13e8:3729 with SMTP id 2adb3069b0e04-5220fc78605mr11784806e87.20.1715901606173; Thu, 16 May 2024 16:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715901606; cv=none; d=google.com; s=arc-20160816; b=Etc9VpchL+/dy33uwdCH+/hzt1Joa9WKHvZh0vm3QblBUCcQVfbxpdkwSvXtYnS+zz MhVf1y56OOfLNjaY4htMpjgmWyssZzDU4O6xN8tTf1fRg6S4Uc9bB2c7dI8g+f+zOOOg pAx4MxlhFY1ls6t+gzOWpSHrJ1cel1XicW0ltYoVBSJrtntIssQpuLROluCEtayrXOjA oVG/FCHZ3YvU8vLBXv9/mG2aP6xwx0IN66eCf9RtFGdC3d3XkiYf/fwggha4yZBvqDDF bShySnRfl/moUYlK6vztuO9qQimlb1Rl5kNiBbabkCY14nMfN5UjNYJyQ8q86Pn7+ykj 39sw== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=4B1BR3Ezvb/ndSuxgT/P5PxUVDg42edmcJXcusOeDys=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=YOgUhkUrpE7q7s2mC8YhSe75DO4TLs+tWOAjN+YJZp8jQIcXOh6fJuYhyM8AUDED3I ZdbE9xC4tqd3lmZaGoRQi8U9flCpufWg5NmOjTP1jxkr1GHRKNim49LQg7Fu/KEAvqZa t28NozJs4uqZHt4IUCgFESCTLIX/+FX+HxTm/HBjYnkR+grIbiNfLAGgSeOTSfuvgvph sfeY9wiHhlVvQUJFUyCd/TifsuX35Lla2sY0ma6var40rjt/HQRfiE6F1iwFfylHEwNF n+2ojwsg0LSxGGzV15FLBZGpgpGE3PFJr32Tgf1G0nosD7hwdMWeZYaGtTUZUnw8BHBx SbZQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=BB9Goq5Q; 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 2adb3069b0e04-521f38da38asi5650216e87.396.2024.05.16.16.20.05; Thu, 16 May 2024 16:20:06 -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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=BB9Goq5Q; 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 4AA6268D283; Fri, 17 May 2024 02:19:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6EB6368D25A for ; Fri, 17 May 2024 02:19:36 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id A81494000E for ; Thu, 16 May 2024 23:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1715901575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EWN60wK9Q2TkVJB3P9ImGeutrUiNObHjgsZXWszhJIY=; b=BB9Goq5QAUvJiv4h2LDRxCY6ryUo3VZT7dTlhkcYxFS8t7NzhlCWl2JLE0HwsumwBG9neo x+1d9Xf4IhJbuROf7vaX+Truz0GADTdDcY+en16T3DesYLs6e7Gd0SV0HxIJg9pT5T6MvA bW+Q7FwCwRD/tFvOMBoOxhvAUepz0k2tcFsGknyhorzQAeyr5OhQ615NJjARHfDMorp3X2 /OvZjGh6KElQoLA9K6zKFU+V9YOpTU2r7FCRrTgUe5Vzda9+Vvzb+HLPLMW+fX5fxLi1gj c+86DC3HuRhjfzcxOqC/RG6N4vrJS0jRdwLASzJXctlcJEJZmG2QcQB3XmGgzQ== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 17 May 2024 01:19:30 +0200 Message-ID: <20240516231932.6950-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240516231932.6950-1-michael@niedermayer.cc> References: <20240516231932.6950-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/scpr3: Check add_dec() for failure 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: yeHOMCKmy7Rs Fixes: CID1441459 Improper use of negative value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavcodec/scpr3.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c index 79106ddcff8..45706123db0 100644 --- a/libavcodec/scpr3.c +++ b/libavcodec/scpr3.c @@ -465,6 +465,8 @@ static int decode_adaptive6(PixelModel3 *m, uint32_t code, uint32_t *value, return 0; grow_dec(m); c = add_dec(m, q, g, f); + if (c < 0) + return AVERROR_INVALIDDATA; } incr_cntdec(m, c); @@ -868,11 +870,11 @@ static int decode_unit3(SCPRContext *s, PixelModel3 *m, uint32_t code, uint32_t sync_code3(gb, rc); break; case 6: - if (!decode_adaptive6(m, code, value, &a, &b)) { + ret = decode_adaptive6(m, code, value, &a, &b); + if (!ret) ret = update_model6_to_7(m); - if (ret < 0) - return AVERROR_INVALIDDATA; - } + if (ret < 0) + return ret; decode3(gb, rc, a, b); sync_code3(gb, rc); break; From patchwork Thu May 16 23:19:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 48940 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp2547044pzb; Thu, 16 May 2024 16:20:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWM9IrMv1WzLB525M1Wqe5GtOuGu1XQQCsrFOAox2RNP2bVeaVWIYT+hJIioEw8ufF8600SLwFf/4rDv5jI6rVtWH7gyBzuj/5k+A== X-Google-Smtp-Source: AGHT+IFS+hRGtSHsv92hYbN2zh3JYFXfDvD4yvr7C5mWTko+nq0tCDMhEqpnzX/mClOyr76d2a53 X-Received: by 2002:a17:907:1b08:b0:a5a:62c9:bdf3 with SMTP id a640c23a62f3a-a5a62c9be77mr1137347766b.1.1715901614931; Thu, 16 May 2024 16:20:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715901614; cv=none; d=google.com; s=arc-20160816; b=SjOhyjNX31cyWY0/CqxtbAV6ybjaUT4J8xbP7yJPAjlBBOnmWhDf3goXz4Gy4CS64p jdtSDeuhnOK3QSIlTnFEO3nxYq/9BwiQ+6QWrFVA66Mgr/AMpA/tsq2OkwgntSTkxKEm 5krsVnVs0csMfLRpIZExwAfXDW1CAWvClnfH3IP928+bPHrxhqaD47lruQcAjFiqNXuj AYkliQiXpPv3Bjs5zzpwkyTRqgIQb8FskXXOfgGcp8yi/Le11gWZc2KKTV8w6qZ86HYY bpeSEBUl2UC7sWOwRt2IQlwfEFcYxJQBk2DQgqolQVO/bGmPi+Kh3U1SV76thd8TDKTg aRFw== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=NFjghdUMSgW5xAiP44OrJv8t1KLfoI7+CmHubccNJ6I=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=ufvWMphVJ08t2iWzVGM0IhL2NYZTEQv1dnCFfPtJDENoX9SuL8wkUXMyKXzm4ZFz6g 5I6/hf6fhRytvil63NB+1ca15QzBgnMuXtSWJE9ir/5pV4/JUAua7jAZSUjhG3vaOWYs r89E8m3cDZr7t4OP4dlzWAS6c+ZObc23I1Ho1/aDGz0jhbLKm9mxgnhDuj7kytrqfutf 4lABUHnv+2YJX8vlvJLiWyjPq4Rqhf33+MDTZ1PIagAsSTCYg44VUOO0fJnYXt3Ey1jx MVbEV5r4YirPKpqGHCO7h5cUACZKA1gwOBYsvTm/d5lJ07SOH0gjR6I/pRFx1frjhRNx KVnQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=i18Mjy2Q; 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 a640c23a62f3a-a5a17946465si859885266b.41.2024.05.16.16.20.14; Thu, 16 May 2024 16:20:14 -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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=i18Mjy2Q; 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 6940F68D2A5; Fri, 17 May 2024 02:19:45 +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 54AE768D011 for ; Fri, 17 May 2024 02:19:37 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9C2A1E000A for ; Thu, 16 May 2024 23:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1715901576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=znNi2BtsEYd54g1gmiZ6eEst+wXqQKGt+K+lsuWfINA=; b=i18Mjy2Q9Rg77OspMhYJjwwHHQRdE69zrxXFro3Wkyf8kHNuPOOTequ1DxNmcHlixn+XQP 11g9wwWCBDk/XW6306ArLtOeFKSSTq2OII2vau75mOy3DW/1A7pT1vGuCjLFr20A2z+xlE 8TOiCXLOlqYsJ4dL7vtNABdoLpDNTlBdHJ0uz1pVKKyfCoqAnA1vKI74v/gUnVnQxVRgtX TISY+/Er4u9WpiiiRHSiMaamJazevH9fvGNFk41i0shogeyLe4zwSysmDTURNiivE1gY/M L3vJrgqbujr8vWzM7pQgFBZGP398vo7mQn4iPXBrNqmpz3WPdlJnXlnAIWNvvA== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 17 May 2024 01:19:31 +0200 Message-ID: <20240516231932.6950-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240516231932.6950-1-michael@niedermayer.cc> References: <20240516231932.6950-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 4/5] avcodec/sga: Check non constant init_get_bits8() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Q8PGnfSK6I9e Fixes: CID1473562 Unchecked return value Fixes: CID1473592 Unchecked return value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavcodec/sga.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/sga.c b/libavcodec/sga.c index 0f42cf912b2..aca941e057e 100644 --- a/libavcodec/sga.c +++ b/libavcodec/sga.c @@ -254,11 +254,14 @@ static int decode_palmapdata(AVCodecContext *avctx) const int bits = (s->nb_pal + 1) / 2; GetByteContext *gb = &s->gb; GetBitContext pm; + int ret; bytestream2_seek(gb, s->palmapdata_offset, SEEK_SET); if (bytestream2_get_bytes_left(gb) < s->palmapdata_size) return AVERROR_INVALIDDATA; - init_get_bits8(&pm, gb->buffer, s->palmapdata_size); + ret = init_get_bits8(&pm, gb->buffer, s->palmapdata_size); + if (ret < 0) + return ret; for (int y = 0; y < s->tiles_h; y++) { uint8_t *dst = s->palmapindex_data + y * s->tiles_w; @@ -277,11 +280,14 @@ static int decode_tiledata(AVCodecContext *avctx) SGAVideoContext *s = avctx->priv_data; GetByteContext *gb = &s->gb; GetBitContext tm; + int ret; bytestream2_seek(gb, s->tiledata_offset, SEEK_SET); if (bytestream2_get_bytes_left(gb) < s->tiledata_size) return AVERROR_INVALIDDATA; - init_get_bits8(&tm, gb->buffer, s->tiledata_size); + ret = init_get_bits8(&tm, gb->buffer, s->tiledata_size); + if (ret < 0) + return ret; for (int n = 0; n < s->nb_tiles; n++) { uint8_t *dst = s->tileindex_data + n * 64; From patchwork Thu May 16 23:19:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 48941 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp2547097pzb; Thu, 16 May 2024 16:20:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVGG/mp7MQVAm3F1rEAfv83gqZ6XFEcpkRZn0gNcmldfm10VNEqNZoPMd+llKgb2qUDnIwVfxicP8ByLregH8jUqYd6AkbG9wiHbg== X-Google-Smtp-Source: AGHT+IGi1DWtn9HSpQ8yrfkZ4Mo6gScRvEKUpbZ3i1vgqWyIdTNzpjp1DHXq6Ata+oEU1t1r0A5R X-Received: by 2002:ac2:4e8d:0:b0:51f:c8f:630e with SMTP id 2adb3069b0e04-5220fc734e1mr12022991e87.35.1715901624077; Thu, 16 May 2024 16:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715901624; cv=none; d=google.com; s=arc-20160816; b=qgir94c7CJPSYpX3XhrgjB+7AyBv90ZdZphih9HTHPc8OzDsBNofhwGaSTO3aRdFFK dwCmRZHZlBC2SIVckUOtnzeiidW0ubonOoeD6kBv4r+3oEeBWXjTfOy7/IgdweqdRqB4 qs0stcyfDZ2m0AmU5UarIW8c5NDk9N1qRuPkOFJwo2x/lHwoX+plWZMtqvrurEPvAk8Z IczGYt8ocnngdbFvP4e0ftQqKNUP/3hWEvLQccq4A8gj3UQO53Gvrsu1Rzzytk/riPCU 78OMRAPy3MyU+wpFRjIIJ9BxSfaHM5orJDJBfklMtdA1AtuW3nK1D9y7C/0rs+dxptKJ buKA== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=h1jkNLJQju7j/aj17xLmgl5c+nA+wM6f7vd+ZA04pAg=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=gxZEhD064FhWhXaRUgj8RgSNMDpN6qQPrfA3dGvZMhEtq5J2QYvqx+pM1l4FXgaqkZ 2K7XwVqTTxzjeT8R2ySxs1kb0Mshn53kozZLeXZ70qLUvXC3ucZjqKCP+Cc4P3xqflqk Z8EwqMUqOXG2qDtEfzAZAhO5Nj/5vc/oFyxCMrNOnYxpNsRgAUc7c6exIyWogNK14bAO HTRCJQDo9e9KWHHuOpXnzyo3vOykVFGTvut43Eugu3LBQBz8MUw71mRhGhfPoPw8Fd2X CvyebDGZSRNPTGXYYpPxFoyVWB6jnaSIO5MPPbnvaDf7e1pa+A38KeKnNtSlCOPjOU8D OlTw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=n9PTpJcw; 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 a640c23a62f3a-a5a17ba3878si898726666b.560.2024.05.16.16.20.23; Thu, 16 May 2024 16:20:24 -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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=n9PTpJcw; 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 8D67A68D32A; Fri, 17 May 2024 02:19:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C81668D2EB for ; Fri, 17 May 2024 02:19:38 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9DAEB20010 for ; Thu, 16 May 2024 23:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1715901577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=etHksJlGMmKbuqxR6zFfI94KZqA6rGLkxaloBGO+a0w=; b=n9PTpJcwK20kJGx0Dpa3YX0SRwrZd8+ZLMXQKv5jVbmv+ZP8cLhNA1FqJjy2P5d9kRYDdy j05L/cwTxTBLu5s9cyNOkzns4oFQFKiLVV6toSPttg/ErWmbPZz9BB/SkQuSLU1V0AI/PV E7pAVAzTWAW+Zr1qkbaFrDhDX5I7VBfKq2suScuqn70MftuqhkOEl5CKYyTrJoyfEXSvik q8FKn8KxFArXjdDkjhuMT4B8fJUV/6iUjv2bzweX7jivk4OE3Mv2tpvbg5LhdRVGBWUktS 4G00T5bkb+wK3zdsmjJ9Fz/UQ9GxB5EIqEAtf7jc/+T3F4Rz3mgCMZi6sD+HYw== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 17 May 2024 01:19:32 +0200 Message-ID: <20240516231932.6950-5-michael@niedermayer.cc> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240516231932.6950-1-michael@niedermayer.cc> References: <20240516231932.6950-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/tests/dct: Use 64bit in intermediate for error computation 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Yu1bAt1boitV Fixes: CID1500284 Unintentional integer overflow Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavcodec/tests/dct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/tests/dct.c b/libavcodec/tests/dct.c index 010d0c1ac35..17a08144597 100644 --- a/libavcodec/tests/dct.c +++ b/libavcodec/tests/dct.c @@ -226,8 +226,8 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c v = abs(err); if (v > err_inf) err_inf = v; - err2_matrix[i] += v * v; - err2 += v * v; + err2_matrix[i] += v * (int64_t)v; + err2 += v * (int64_t)v; sysErr[i] += block[i] - block1[i]; blockSumErr += v; if (abs(block[i]) > maxout)