[{"id":14029,"web_url":"https://patchwork.libcamera.org/comment/14029/","msgid":"<20201201191006.GA4569@pendragon.ideasonboard.com>","date":"2020-12-01T19:10:06","subject":"Re: [libcamera-devel] [PATCH] android: camera_device: Check\n\tcapture_request validity","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Tue, Dec 01, 2020 at 05:14:45PM +0100, Jacopo Mondi wrote:\n> Make sure the 'camera3_capture_request_t *' provided to\n> CameraDevice::processCaptureRequest() is valid before attempting to\n> access it.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n> This patch fixes cros_camera_test:\n> Camera3FrameTest/Camera3InvalidRequestTest.NullOrUnconfiguredRequest/*\n\nMaybe this should be included in the commit message ?\n\n> ---\n> \n>  src/android/camera_device.cpp | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 4eb05df0fdc2..3c8205a095ae 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -1398,6 +1398,11 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer\n> \n>  int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)\n>  {\n> +\tif (!camera3Request) {\n> +\t\tLOG(HAL, Error) << \"Invalid capture request\";\n\nI'd say \"No capture request provided\" as it's more than invalid :-) Up\nto you.\n\nI wonder if the cros_camera_test case makes sense. There are lots of\nways to exercise APIs in ways that are completely against API contracts,\nit would be pointless to check them all. This isn't about parsing a file\nor network data from untrusted sources, we can rely on the camera\nservice doing its job more or less properly. We can't really influence\nthe tests much though, and this fixes an issue, so\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\treturn -EINVAL;\n> +\t}\n> +\n>  \tif (!camera3Request->num_output_buffers) {\n>  \t\tLOG(HAL, Error) << \"No output buffers provided\";\n>  \t\treturn -EINVAL;","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 75E23BE177\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Dec 2020 19:10:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 11CB563501;\n\tTue,  1 Dec 2020 20:10:17 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7707663460\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Dec 2020 20:10:15 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DC254DBD;\n\tTue,  1 Dec 2020 20:10:14 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"r70BYBAi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1606849815;\n\tbh=gCswjNWDBR6PhZa/wZpuFpYFBeU/IQJL/2o+TqGYpB0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=r70BYBAi/72Ps+ZRZJm9yoxPYA+YexYuz83fpSAYQrnBheCxxCj15VFHihsMaHDf+\n\t0p+ClRuXPxUJ7hj/hMDyalnJtsWi56l/pEr2vEKxEdCMuk1bTvmnLCyGZFQrmu5qzc\n\t9vbMTKZtGpn7Bhjm4EZ4HCqyZDIPgd46aQ//U7Sg=","Date":"Tue, 1 Dec 2020 21:10:06 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20201201191006.GA4569@pendragon.ideasonboard.com>","References":"<20201201161445.64114-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201201161445.64114-1-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH] android: camera_device: Check\n\tcapture_request validity","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"hanlinchen@chromium.org, libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]