From patchwork Mon Feb 26 09:48:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 19540 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B60C9C3264 for ; Mon, 26 Feb 2024 09:49:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2877562870; Mon, 26 Feb 2024 10:49:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ODslC0Rq"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2668562866 for ; Mon, 26 Feb 2024 10:49:01 +0100 (CET) Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B597ED52; Mon, 26 Feb 2024 10:48:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1708940929; bh=LSuKu9Oe6ysCXWBP5fJj8F/wM0Z5lIqSbqC3xd7U3Q0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ODslC0RqwS6N1we5gjfyL9s/c26NKAjvKwFphTTxd798YYSrg4Os9R2QwDAovYUl4 bYbauONw5YnS5aPgVKRrnCXpi29Zs1D2E104EggmWBnw2jdvuwa9zXpRt9z6ZpJj2G 4czw8AhmF2y9z/6uO79z8RvqyahpO7C94H/JbM64= From: Kieran Bingham To: libcamera devel Subject: [PATCH 1/2] libcamera: formats: Fix planes bounds check Date: Mon, 26 Feb 2024 09:48:56 +0000 Message-Id: <20240226094857.2207313-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240226094857.2207313-1-kieran.bingham@ideasonboard.com> References: <20240226094857.2207313-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johan Mattsson <39247600+mjunix@users.noreply.github.com> Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The plane validation in the stride helper incorrectly accepts the number of planes as a plane index. Fix the off by one issue. Reported-by: Johan Mattsson <39247600+mjunix@users.noreply.github.com> Fixes: e83727a194b5 ("libcamera: PixelFormatInfo: Add functions stride and frameSize") Signed-off-by: Kieran Bingham Reported-by: Johan Mattsson Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/libcamera/formats.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 447e623803c7..c11fbd730c8e 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -987,7 +987,7 @@ unsigned int PixelFormatInfo::stride(unsigned int width, unsigned int plane, return 0; } - if (plane > planes.size() || !planes[plane].bytesPerGroup) { + if (plane >= planes.size() || !planes[plane].bytesPerGroup) { LOG(Formats, Warning) << "Invalid plane index, stride is zero"; return 0; }