From patchwork Mon Sep 12 20:57:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 17365 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 9CE87C0DA4 for ; Mon, 12 Sep 2022 20:57:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C2A6E61FA0; Mon, 12 Sep 2022 22:57:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1663016229; bh=W3QBKQVFpd01YQgeD3z0VFP06YZcTQmsSfMLjNJdewM=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=0ce8PUOJHketRPD1O5GykQJA4obunP3WabxAWx5vv4ZAPjDUpMCAd2y3ysmp0hPTP Ef3BuRAB0dkEdGx5fxU2mHaEaM2h4nqrWhhtkc/tQhUStgsCYh9/Jf+843g6qUa7Fr 7ug4YPvG2qL+9Yvq9mTZq4i0ulHm86YSab6S8tKdNIp1u96nzkaFT9G49JA04NDHFv 7+tgLbMOOdad24NLeONmAfebW8IqJR8lyimXiLaELrWVp5oh/vZL8hQjO+LdPLq0ok QD1HDuLy8crTW/mRkrLQ3I4wUZ2QYVX1fsTykeudFq5/oFSi8i8poPIZoew5l38owp 1pIg7BjVB3rbQ== Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A025D609A6 for ; Mon, 12 Sep 2022 22:57:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="CZQsq0qc"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1663016228; bh=W3QBKQVFpd01YQgeD3z0VFP06YZcTQmsSfMLjNJdewM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=CZQsq0qcd67ksFKBgMxwp+QLGwQfdxxLV6WtkqWGQi5OHoltnNx+BWv8Vi3Hf1o8e j4edWwhBzaDATakPG1EHfv3trq9rGBZ6D+ICoO+WVtCInj1qEW3+Q2ajb6v5rlZuyx Xm1xEzMokxlIAKAEs+TeFFBxYdimUWF9RKHuqWwM= 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 1MRTN9-1ojiTZ0VBl-00NUNN; Mon, 12 Sep 2022 22:57:08 +0200 To: libcamera-devel@lists.libcamera.org Date: Mon, 12 Sep 2022 22:57:05 +0200 Message-Id: <20220912205705.83029-1-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:wMb9Sr6qMcV0XCFFVJNjcdFZKvd6657m48Itj4sz2qQrDGTm6Vv X13QFlaOaMP3hYv2LMX7kjFda5ffzCDvsxpyH5EzTkes/SsUwiz6kyKHpNRcyJ8QgrkiggI 3jcqxMbEc3e0OeHEdS5cR95jWHayAsiuFHTtxYzwNe+cFaIvVR8L/tWjJEUmxvWWsNYnZEi idyqtV6pQusGPifdVC0EA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:ZxsYpDIcl3o=:vjZ9alcazlkXWHH/Eif18M iTEI3ic8QMUJm2o7Hg7QPRFVgNc58yA0nIRYqkHlEnJNHz5Xyxei0x5p1Px8TjDGZdYYgqmrE mGgBZKWy4L6a3xILCOfAFTw17nPzFmFMzOFeBtknJToqH4mQ9N5ekMCGqz3Op5e5mIDnxrIE7 hkSxggrTeaGia8iKdBeGUJ0itx6aPcjo5CtkwoYul0IwfCDxKrC/1E9YCmqzaA9w0C9TM0olL A9QGmnYZr2G9YTERozLE9vd2LnlDFNOWAZNxs69tfyZf17ACQNW9K+NZTcQs2yjxgREoVplr4 aBSaZLiRX9J4Ur4xIkwx/E+xLeY6KbU573uz3lkpMGXGxU7EEJt6c0LkGrIOf3OV07Ru47m5o /l03/L3TdhChTc62fNX0RBKuj31aecUVFF756Ue0K0ty/QUXhwju8S6IrW9UUgB6rIcS/34pO SS+pbCHg0KLQFpRhldWoJVqyc8UgrYUfaalOWQVRVXZQirarxE5BWAb04NCbRVSSDzeHrD+SC 7Wku2GeSdteXfKHF4eeDyRnn8QkIhXYG7c3hBEG+oheG2Jd0Qi+4SdGfD5j4QzVZTKdQPF6yy 1IuxvNVAS9YNrgDsN1vT+FnW/uPYXNxDIdk9063+Jx5Ph2hQx5ZRoLtbd7k3IeLxlI8DXozve RismC1OGX/i+rrl9gnkS5AaLsEtWbgezbdMni+JFyCaniC5tIRijdepYi+qvZAh7I0UYJMbks qHzPgiIpQe+oU/3R78CRllHrKE3NtASgWpVuAUVc8unao3epmWoADd8A6PLPPaA25TcTeHQ0j RMKqoN//5UBe0Lc2in0j8BfgehqLpxDxRyMIeK+59/Mr3azGO4MM/uHAohPRIQIVM3AsRJ1b5 qKQM9Pv9O/SlN0Gi5Np3fC+ToJm15SXfEENBfj2WNAMj4MhfSze9uQxOZ2nOIBNQ003ck7EK6 KbQu4aFwXONH1NnOEzqGF1QQmwbguWmHz/F3yECV52I15cI6VXmu0JhgctnChvNMVfzxO79kY /nakcgEG+m/wakwTGdtvzAHJyj6k13KTMn0UHOcK9z5Er+jM+W3OXsQdR/qiQqd1cshBzxURo bAe+FUfK6VxOLz4TScRmsIIfkgPSSqNRVZuxnorj6b/aO8bjRF/t7tSaOY1kdzG+MIeKsaQoF a8IrFLohvZxl25Jkgvm2oEbZup Subject: [libcamera-devel] [PATCH] 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 --- src/libcamera/controls.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.34.1 diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index bc3db4f6..040257c5 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -701,6 +701,20 @@ bool ControlInfoMap::validate() ? ControlTypeInteger32 : id->type(); const ControlInfo &info = ctrl.second; + if (info.min().type() != info.max().type()) { + LOG(Controls, Error) + << "Control " << utils::hex(id->id()) + << " range types mismatch"; + return false; + } + + if (info.def().type() != ControlTypeNone && (info.min().type() != info.def().type())) { + LOG(Controls, Error) + << "Control " << utils::hex(id->id()) + << " default value and info type mismatch"; + return false; + } + if (info.min().type() != rangeType) { LOG(Controls, Error) << "Control " << utils::hex(id->id())