From patchwork Wed Jun 3 14:16:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 3906 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5CC2C6114D for ; Wed, 3 Jun 2020 16:16:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="D1oqqPGl"; dkim-atps=neutral Received: from emerald.amanokami.net (fs76eef344.knge213.ap.nuro.jp [118.238.243.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 179F527C; Wed, 3 Jun 2020 16:16:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1591193785; bh=zkkZ8HpwE1KadJjjp80IveswbRW2zPq0Smm8x52nocY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D1oqqPGlRIDDGh6Y6IohlvH92L4nOYZR2zRZLOdccGNbTlz1NlC5MnMqBDh8uH952 Huiah4wsrwh1HCVhZxi/iXVqEIe9VJW74ArVyXaSn761AfZ8akHzOGZU8+2Ls2Kz7j GF76OlvPgjwE2Gf7LzTS2cMhugu4NLpuduA557iw= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Jun 2020 23:16:06 +0900 Message-Id: <20200603141609.18584-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200603141609.18584-1-paul.elder@ideasonboard.com> References: <20200603141609.18584-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] v4l2: v4l2_camera_proxy: Fix bounds check for VIDIOC_ENUM_FMT 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-List-Received-Date: Wed, 03 Jun 2020 14:16:26 -0000 VIDIOC_ENUM_FMT is meant to return -EINVAL if the requested index is out of bounds. This bounds is obtained from the libcamera Camera's list of formats. The bounds check for this list was incorrect; fix it. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- src/v4l2/v4l2_camera_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 3df4d42b..ec6d265d 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -224,7 +224,7 @@ int V4L2CameraProxy::vidioc_enum_fmt(struct v4l2_fmtdesc *arg) LOG(V4L2Compat, Debug) << "Servicing vidioc_enum_fmt"; if (!validateBufferType(arg->type) || - arg->index > streamConfig_.formats().pixelformats().size()) + arg->index >= streamConfig_.formats().pixelformats().size()) return -EINVAL; /* \todo Add map from format to description. */