From patchwork Thu Sep 22 20:22:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 17388 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 604CABD16B for ; Thu, 22 Sep 2022 20:22:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 20AC26221C; Thu, 22 Sep 2022 22:22:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1663878138; bh=PcL+eoj9Jtgm+1kZtHNjrEX6V+jh5KtqDtDgpCNj2LE=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=POlkcV0c6E6UaMtf3R+R37D4bc8mvbgfRCdIAWrB4k7URk0Xk/VU/3QKWKvl2je7Z wtHGDNo2PMUG4FHYgX6IjVePC4HJNjzgG2Eklp0s4PZaGj5cRbxApNP6gQQIX64mzk iA5Fqw9IMDtZYqG45VkqnOQqKA9G+XsFdEMT3/HOkDs8ly0TGnZMlKQjS7N0LPClFm EyO+WcZ+LUt9VTjqLW+hh9BHyXYEuo/dfW0liZDfZbwrFi6r/9KB5hyorW7hLoPmlL ZZMumOSr7xaoKCgqLD0E1iDxgclEwfgZpMIlYAb31g9RYJwEIE4Ct8e76dhHZ/ceK0 G4/nRAcYkH/zA== Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CF01662217 for ; Thu, 22 Sep 2022 22:22:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="Dm7iNZo6"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1663878136; bh=PcL+eoj9Jtgm+1kZtHNjrEX6V+jh5KtqDtDgpCNj2LE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=Dm7iNZo6Y0US24dGCFoKG/Rimfs9NuSBZJsVPjHasKdQt8GeTms8mZ78Num+yUmU8 z5hxNefO2nPTBUyKkzFHJs8t0s3B4h0jKDHPSECeG9/jfy38YrtGDrBpOpYK778pbS gGmbaP57o5vQxCMnWKmW/t8nK3I20n6ldeLMmgwM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from voyager ([88.152.184.103]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N79yQ-1pKPsS0vwC-017VCX; Thu, 22 Sep 2022 22:22:16 +0200 To: libcamera-devel@lists.libcamera.org Date: Thu, 22 Sep 2022 22:22:13 +0200 Message-Id: <20220922202213.582824-1-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:NVJb3g35PYH6NTUvrZgBLLkPXjCdg8WzGFXDyUxFr07z8ZHVYDh BhEQDnFsuQcFleWWOIiHKd/1C0k6S29S1JKwvaPzrjtHY8EgFw+hYsRwtqxKYaIMURFz9Cv cNllKMHKMlT40nsNKLfr14o58V4VmO0/zCIHVVLeuJSu9MWovv8VaTuj7oU+oTYLwzxGxoR ICiYGyJwpRhrOmLPag+wQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:6YVXeFreqV8=:osesdX5MjbvqyKrVm8R/iq 8IItSKs9CzVZ/iHF2bvW1eAW2iedmIoQ8qUYrOamiRl+gyWSEcmOLQ73LvOcJzSkh/GOMkTyH IGSq3FmaXW9FTLAm81A3+mX1tEcwBxvZ4P9FJBcTyMKiO/QO40NG2i71vZZBJMJuwXNKC7m9p 81ApvtDWbVfLg+wZsqvNQcVFwiAbz7fq6qU5h1uM6EhIZIHPCUNq3nL5rjfmaA/tqf9G4LTic 2zCovbO2PsZuloGF/8R7iCt2qbaTtwiFqMn8RtwCBAmxC2ZKTaRXiOpEVEyP8lF7CSapomj/M MTmyxnheWjcYMpAXQ0HRBOgeRBJW8jFTfDXtzwBUEnPhnwPOeag4ZxQkqjbZLbREQ6owckRL0 /gisFUqgbMhE0r+8wUzWn7mtiG1w820YeygRVsBLSNiG64UVCsvaNxI83ghYlZFY1z+p27eiW CML0SZtI9+g7EFX389/kfKds1YUg54+FFKcfqTsHN28BUsXXhzwXNmALh3nDyWoqE/0Ghv+xD JXRN1vd3TP483WI5bPGdPMDKfSF2HcwXwz1aNX9h10pBd0x22u1XvI/LCh+00x25thsc8KngQ BrbLIemBScOsbFWTYPGWiWq4Zkmnu0ogc8iSbxtIitQIqdueZ3Wbm5VTrgZHrnsiVbqNIFsd4 XObryzpX3WhE8U767olbv9TGKyVClzfHxAj07lcIKJD8ahofI5AXZeF8eg62475EZ40gcXYJy eNJ7BgEu9siOYSt5f6A5SYVYoMt5LmTVxr7OQ9cdwPFMXyXfZ7WpXS3JiYlSVLjWqidRrAGNo +BCGbxw294mk2ULwnmf2U5AaFZAYZUw/S9uJqXZ2+8YBf0OrYDYJm81a5tAlMu/IzsMyil7++ cWHAVoIerJaO1TqRb+NJtuMXqdiBFsJ3Wpa2H6c5Ftmeb1oOroqysjxHt0dokFdUA7XZ9scbh FUKX+gnOSj7Q+AekKVbKnbTr24xFH6RgpnZVnsYpf71yF7hiNkn2IP1Nf/br1X3uoF7RjwPAD hOgQQKOOWsQnFM4ah8XtJvyXZZukg4Jde35dE4jWe4IDQ0O8ccSuqUB6XYWe4asgz1yxCiMEo sfgDdSXrLV0Q/+STHECTzyflXfxSwY7bZeF70yAAd9UKVIylwobZyd9SOD4RNs2FSyrrF+hZq X248ZxCWApg56urBAcUekT+OME Subject: [libcamera-devel] [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" 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; }