From patchwork Thu Oct 6 18:18:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 17552 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 5F86FC0DA4 for ; Thu, 6 Oct 2022 18:18:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B387B62CF2; Thu, 6 Oct 2022 20:18:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665080337; bh=hdH3NdwaG0DzeGnQT2oVeZZnBXm2BVkISqKRA0fNCt4=; h=Date:References:To:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=1s8SgUyvhsoMzrVWXk3fpXDULvQfLPhD6jR5EJGx5eXcbU7JPL6IacIrQPM025g3r UUEpebTUvygarZ3NnBcIVEqOUdCvzZM70s9Vge2LkAW2FNXPQHovy1r8o5lFZEF7BM NVDdF4EPvsBeYAt+sv63Q4dkOxPOnFK7z+ydylZPDMT3HCe3jmtkNUxF8RXjs52HB9 2ogiQzv+R1SL3xRofKnCEvlnRAgKFslj2JVsbFn0LUfL00pJugJjgK8INfN9Jmb3RN QQlxd22WmnSHWcodkToWxSsZG+hIiq6HxduzX9Q3AifzwSBDHS6+afJOe97pJzQaPi JZKFY1/gUxbfw== Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F16C62CEC for ; Thu, 6 Oct 2022 20:18:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="iD7sttvh"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1665080335; bh=hdH3NdwaG0DzeGnQT2oVeZZnBXm2BVkISqKRA0fNCt4=; h=X-UI-Sender-Class:Date:Subject:References:To:From:In-Reply-To; b=iD7sttvhFaVI//pwyvwCcCeXGZldfnDpKwAmgFDaal6mC0qV1szZl7Vtl0sGptMt1 DbajBJS158SMO3UrfOXfnO68kWQ28HHre9jmYR6pWlCRp1Mc0QtoWlJwoQktBCzdap X/i9RY9czplUmG/vO3yki4aw4gO89oF7RErawHhY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.0.158] ([88.152.184.103]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MHXBp-1oT3Co2uI5-00DTZu for ; Thu, 06 Oct 2022 20:18:55 +0200 Message-ID: <83a11c1c-c9a9-3aa7-30f4-5c0d257483b9@gmx.de> Date: Thu, 6 Oct 2022 20:18:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 References: <20220922202213.582824-1-Rauch.Christian@gmx.de> Content-Language: en-GB To: libcamera devel In-Reply-To: <20220922202213.582824-1-Rauch.Christian@gmx.de> X-Forwarded-Message-Id: <20220922202213.582824-1-Rauch.Christian@gmx.de> X-Provags-ID: V03:K1:iANQ2c4vJMsjRh+OxYi3ynTeyHi32mNdMH44ACD95m+Z+Jejm8J lP1MsL3dTqv08W1b6gPJUbwSJ6Eh7q/+DZ5MfmBXLjo65gQqDrnsGtiEYSMoDU/k0Fnvk3G TpWBaead7F/WlBHfB+nF4HMbCkuhWmEEngtekJO3Hjc4e0Lf8gIaEyNVv93gkyyecF1F09I JDI0W/uVbCEcP7cDAwQ1A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Y5A8uw5m5IA=:3d14WnGD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qJhCQgnsMI2R7K4HuJq231wwjiZsXijeuk+e9 Hl0gRJ1W+K/THTjV5R+4UTSZ9P5E52lnfOHObUqojNRc1YL5JJs9Rf2Nd8OfHYMhxRlfz0rcz AosZfzu5+sPPSkvnTiETkbLhCwnz/ECw24jofiFxCaE+UDDJ7VzhdH3FEZj0ZZcPsFMROw5Yu Pma0wrkF8WewZh6xKgVyH+U023PHeHOSkNaikt7f0DkXWaOPRP0zEsqKWFuYK7+GX5pNWP9TH E2HbVH7rHWeN6st8MkDDRa/ImamKXxHysx5EqFD9hIrRkBLHQhf+L9XO3qVu7EGBgQpLvCidI sfwOx6U8LeRmNiOpXD6ztt7Rpd8R2J5nyKc9lR9o7SAI25WI2DpACN68WB4N5NNuz73PDeGg9 f7PrDY0/BkIhmeVoDTrSGgu6PVVYtkUr+of2Hv8y44B1EAEDet3brM/njGbt1KN+a7MfARCkD l++7YooQCHUUKCzLiJVXF/dNwqdic2C5qbA/mH0kSEb53 Subject: [libcamera-devel] Fwd: [PATCH v3] libcamera: controls: validate all ControlInfo values 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: , X-Patchwork-Original-From: Christian Rauch via libcamera-devel From: Christian Rauch Reply-To: Christian Rauch Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi, I am just forwarding this again to see if there is more feedback or interest in merging this in the medium-term. Best, Christian -------- Weitergeleitete Nachricht -------- Betreff: [PATCH v3] libcamera: controls: validate all ControlInfo values Datum: Thu, 22 Sep 2022 22:22:13 +0200 Von: Christian Rauch An: libcamera-devel@lists.libcamera.org Kopie (CC): Christian Rauch , Kieran Bingham ControlInfoMap::validate only checks the 'min' type against the ControlId type. Extend this with checks against the 'max' type and the 'def' type, if a default is specified. This forces the min/max bounds to have the same type as the controlled value, but leaves the default optional. Signed-off-by: Christian Rauch Reviewed-by: Kieran Bingham --- src/libcamera/controls.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) -- 2.34.1 diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index bc3db4f6..1e54a712 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -701,9 +701,32 @@ bool ControlInfoMap::validate() ? ControlTypeInteger32 : id->type(); const ControlInfo &info = ctrl.second; + if (!(info.min().isArray() == info.max().isArray() && + info.min().numElements() == info.max().numElements())) { + LOG(Controls, Error) + << "Control " << id->name() + << " range must have the same dimension."; + return false; + } + + if (info.min().type() != info.max().type()) { + LOG(Controls, Error) + << "Control " << id->name() + << " range types mismatch"; + return false; + } + + if (info.def().type() != ControlTypeNone && + info.min().type() != info.def().type()) { + LOG(Controls, Error) + << "Control " << id->name() + << " default value and info type mismatch"; + return false; + } + if (info.min().type() != rangeType) { LOG(Controls, Error) - << "Control " << utils::hex(id->id()) + << "Control " << id->name() << " type and info type mismatch"; return false; }