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;