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; } From patchwork Mon Feb 26 09:48:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 19541 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 DC4D9BD160 for ; Mon, 26 Feb 2024 09:49:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CD6946286C; 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="K53nUjye"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E27A6286B 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 0419A15C4; 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=1708940930; bh=hc3m/NVGQaCCRxmZpE2YxJwJ8sbmbrr9QnyXP4wBDzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K53nUjyelbar6yautxNwK8YuhyzVc7ImXeuOCpJKY5UZMCk8fpZXCB7J3uhFlm5aJ XQVT9NOyn5keG7qumXUGbRCx1xwT4LzDFVCOS9CSsriXSnKMftia4xGI/5O87+YosO Z83ADHpDI03iqd3a36ljKR+X2wMGDPZ9J2Zy7lbA= From: Kieran Bingham To: libcamera devel Subject: [PATCH 2/2] utils: ipu3: Fix return value check on file output Date: Mon, 26 Feb 2024 09:48:57 +0000 Message-Id: <20240226094857.2207313-3-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 data parsed by ipu3-unpack is written out using the write() c library call, but the error code is incorrectly checked which misses the single erroroneous return value returned by the function. Fix it to explicitly check against the error code. Reported-by: Johan Mattsson <39247600+mjunix@users.noreply.github.com> Fixes: 23ac77dc4a09 ("utils: ipu3: Add IPU3 raw capture unpack utility") Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- utils/ipu3/ipu3-unpack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/ipu3/ipu3-unpack.c b/utils/ipu3/ipu3-unpack.c index 9d2c1200d932..c96fafed2435 100644 --- a/utils/ipu3/ipu3-unpack.c +++ b/utils/ipu3/ipu3-unpack.c @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) } ret = write(out_fd, out_data, 50); - if (ret < -1) { + if (ret == -1) { fprintf(stderr, "Failed to write output data: %s\n", strerror(errno)); goto done;