[{"id":24631,"web_url":"https://patchwork.libcamera.org/comment/24631/","msgid":"<20220818121222.GF2412817@pyrite.rasen.tech>","date":"2022-08-18T12:12:22","subject":"Re: [libcamera-devel] [PATCH v4 4/9] libcamera: yaml_parser: Fix\n\tbounds checking for 16-bit YamlObject::get()","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"On Tue, Aug 16, 2022 at 04:54:09AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> The YamlObject::get() function specializations for 16-bit integers cast\n> the return value of strto(u)l() to a 16-bit integer, rendering the\n> bounds checking useless. Fix them.\n> \n> Fixes: c7d260c03abd (\"libcamera: yaml_parser: Add get() specializations for 16-bit integers\")\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/libcamera/yaml_parser.cpp | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\n> index 9162e2250ed4..f928b7238a19 100644\n> --- a/src/libcamera/yaml_parser.cpp\n> +++ b/src/libcamera/yaml_parser.cpp\n> @@ -143,7 +143,7 @@ std::optional<int16_t> YamlObject::get() const\n>  \tchar *end;\n>  \n>  \terrno = 0;\n> -\tint16_t value = std::strtol(value_.c_str(), &end, 10);\n> +\tlong value = std::strtol(value_.c_str(), &end, 10);\n>  \n>  \tif ('\\0' != *end || errno == ERANGE ||\n>  \t    value < std::numeric_limits<int16_t>::min() ||\n> @@ -176,7 +176,7 @@ std::optional<uint16_t> YamlObject::get() const\n>  \tchar *end;\n>  \n>  \terrno = 0;\n> -\tuint16_t value = std::strtoul(value_.c_str(), &end, 10);\n> +\tunsigned long value = std::strtoul(value_.c_str(), &end, 10);\n>  \n>  \tif ('\\0' != *end || errno == ERANGE ||\n>  \t    value < std::numeric_limits<uint16_t>::min() ||\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","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 8048EBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Aug 2022 12:12:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C0C4161FC0;\n\tThu, 18 Aug 2022 14:12:30 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C41D061FA7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Aug 2022 14:12:29 +0200 (CEST)","from pyrite.rasen.tech (KD027085204050.au-net.ne.jp [27.85.204.50])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5415F8B;\n\tThu, 18 Aug 2022 14:12:28 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660824750;\n\tbh=fEJsU7y8vnea78ggh6wOk8vGQXo9DK6Twl1D1oMKfcw=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=DKLSx5/C2rJxAexzfkaNsulG/O6L8FBwezdOnMEZ7VacNygiJQhGigIGv/OdwnMUf\n\tDPDybryubVmgPStnlbmST7lZvkKUTHamUedbkLMzvpFG4Q1UAl1/DgNAiKBxkFgjXW\n\tbgtwa/QgwEN8/8omgL4Yn4Jzvv4S20Yy+feDNi7BBzgrZQlUYArVMYT51fgJbdW2i8\n\tdW6XTT4YXjEF+0enGbkq2sabZTVZq3hICymaQeveED2NkzrZ5dEC/9uP0AYxwcRzvt\n\tuMXf36Q2GyoyB2qBpUmxYBpq8vPYSKYA4xnTJAZo/Rerc4wXx2cBkdiZp+hLHGtEuY\n\t6Tf2yAOxqOzmg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660824749;\n\tbh=fEJsU7y8vnea78ggh6wOk8vGQXo9DK6Twl1D1oMKfcw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=hKCw/VPi5fjGsTISpxARiALLW3Uars0UpUar3KrAW7NP0VWwlMexJmRr724KbDk1W\n\tJn507sxtqAdjSte9in/HXiWRCff6MMaBpGtR/ucv+4Hx3lXfabXXdUTd9TS8Jq3J0q\n\tTOcelF9Qf1Rbolj/TQMUamEtxC2qgriP2hDWS0qI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"hKCw/VPi\"; dkim-atps=neutral","Date":"Thu, 18 Aug 2022 21:12:22 +0900","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220818121222.GF2412817@pyrite.rasen.tech>","References":"<20220816015414.7462-1-laurent.pinchart@ideasonboard.com>\n\t<20220816015414.7462-5-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20220816015414.7462-5-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 4/9] libcamera: yaml_parser: Fix\n\tbounds checking for 16-bit YamlObject::get()","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24637,"web_url":"https://patchwork.libcamera.org/comment/24637/","msgid":"<20220818130303.iplvzwkru6elkokz@uno.localdomain>","date":"2022-08-18T13:03:03","subject":"Re: [libcamera-devel] [PATCH v4 4/9] libcamera: yaml_parser: Fix\n\tbounds checking for 16-bit YamlObject::get()","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent\n\nOn Tue, Aug 16, 2022 at 04:54:09AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> The YamlObject::get() function specializations for 16-bit integers cast\n> the return value of strto(u)l() to a 16-bit integer, rendering the\n> bounds checking useless. Fix them.\n>\n> Fixes: c7d260c03abd (\"libcamera: yaml_parser: Add get() specializations for 16-bit integers\")\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nGood catch!\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> ---\n>  src/libcamera/yaml_parser.cpp | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\n> index 9162e2250ed4..f928b7238a19 100644\n> --- a/src/libcamera/yaml_parser.cpp\n> +++ b/src/libcamera/yaml_parser.cpp\n> @@ -143,7 +143,7 @@ std::optional<int16_t> YamlObject::get() const\n>  \tchar *end;\n>\n>  \terrno = 0;\n> -\tint16_t value = std::strtol(value_.c_str(), &end, 10);\n> +\tlong value = std::strtol(value_.c_str(), &end, 10);\n>\n>  \tif ('\\0' != *end || errno == ERANGE ||\n>  \t    value < std::numeric_limits<int16_t>::min() ||\n> @@ -176,7 +176,7 @@ std::optional<uint16_t> YamlObject::get() const\n>  \tchar *end;\n>\n>  \terrno = 0;\n> -\tuint16_t value = std::strtoul(value_.c_str(), &end, 10);\n> +\tunsigned long value = std::strtoul(value_.c_str(), &end, 10);\n>\n>  \tif ('\\0' != *end || errno == ERANGE ||\n>  \t    value < std::numeric_limits<uint16_t>::min() ||\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","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 160C7C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Aug 2022 13:03:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8E69B61FC0;\n\tThu, 18 Aug 2022 15:03:07 +0200 (CEST)","from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::226])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 503C061FA7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Aug 2022 15:03:06 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 907C5C0007;\n\tThu, 18 Aug 2022 13:03:05 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660827787;\n\tbh=9crRIrewImc6CUaH7NSA5tvA9Eq/RoaKjuPUCMGT1yU=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=GZlykz7zIMFL4GoHJN0UL8092LGehSMvHr4U/6RKyLYzCcQNBAZj62kMhcEcNTO45\n\tsIdugcrE1FAYLBrU+OTvKL3Fm963TPAE29Q/hGDBZC0SxiZjwn2rEip77tDc3EnwUQ\n\tbEg26PMrONhzIj5O3XanWe8vaguzE/RLfpTPMinIW9+E9zGRwK7lAxcfprQKof9xTS\n\tc2Ap1AhR/y22Yqvgj/FzkwlwduWDFXsp7lv9YCsRr9woc5+xuxdnLOkIyb4RMTOn9s\n\tn6ch8GdEMbvx39tQjD6BaT1tngr6Ht2qvhXK6pmP3Nb5gR+P5eabs4NImOBoLtdQnY\n\tV+BTnHLgP8srg==","Date":"Thu, 18 Aug 2022 15:03:03 +0200","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220818130303.iplvzwkru6elkokz@uno.localdomain>","References":"<20220816015414.7462-1-laurent.pinchart@ideasonboard.com>\n\t<20220816015414.7462-5-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220816015414.7462-5-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 4/9] libcamera: yaml_parser: Fix\n\tbounds checking for 16-bit YamlObject::get()","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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]