[{"id":30469,"web_url":"https://patchwork.libcamera.org/comment/30469/","msgid":"<2p5gdrbnr5o5kk66sugkr6cer53c63lng32kmumo5m54ygjrwe@bg2md2nmxdp4>","date":"2024-07-24T13:13:21","subject":"Re: [RFC PATCH 3/6] libcamera: yaml_parser: Increase sentinel to\n\t100k","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"I admin I have no idea how good or bad 100k is as a limit\n\nOn Fri, Jul 12, 2024 at 10:59:17AM GMT, Umang Jain wrote:\n> From: Xavier Roumegue <xavier.roumegue@oss.nxp.com>\n>\n> Instead of manually increasing the limit, prepare a constexpr\n> for maximum sentinel and use that instead.\n>\n> Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>\n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>  src/libcamera/yaml_parser.cpp | 9 ++++++---\n>  1 file changed, 6 insertions(+), 3 deletions(-)\n>\n> diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\n> index 025006bc..09ed75f1 100644\n> --- a/src/libcamera/yaml_parser.cpp\n> +++ b/src/libcamera/yaml_parser.cpp\n> @@ -690,6 +690,8 @@ void YamlParserContext::readValue(std::string &value, EventPtr event)\n>  int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,\n>  \t\t\t\t\t     const std::function<int(EventPtr event)> &parseItem)\n>  {\n> +\tconstexpr unsigned int maxSentinel = 100000;\n> +\n>  \tyaml_event_type_t endEventType = YAML_SEQUENCE_END_EVENT;\n>  \tif (type == YamlObject::Type::Dictionary)\n>  \t\tendEventType = YAML_MAPPING_END_EVENT;\n> @@ -698,7 +700,7 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,\n>  \t * Add a safety counter to make sure we don't loop indefinitely in case\n>  \t * the YAML file is malformed.\n>  \t */\n> -\tfor (unsigned int sentinel = 2000; sentinel; sentinel--) {\n> +\tfor (unsigned int sentinel = maxSentinel; sentinel; sentinel--) {\n>  \t\tauto evt = nextEvent();\n>  \t\tif (!evt)\n>  \t\t\treturn -EINVAL;\n> @@ -711,8 +713,9 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,\n>  \t\t\treturn ret;\n>  \t}\n>\n> -\tLOG(YamlParser, Error) << \"The YAML file contains a List or Dictionary\"\n> -\t\t\t\t  \" whose size exceeds the parser's limit (1000)\";\n> +\tLOG(YamlParser, Error)\n> +\t\t<< \"The YAML file contains a List or Dictionary whose size exceeds\"\n> +\t\t<< \" the parser's limit (\" << maxSentinel << \")\";\n>\n>  \treturn -EINVAL;\n>  }\n> --\n> 2.45.0\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 7ECEFBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Jul 2024 13:13:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1A4F363370;\n\tWed, 24 Jul 2024 15:13:27 +0200 (CEST)","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 A6DB363369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jul 2024 15:13:25 +0200 (CEST)","from ideasonboard.com (unknown [91.80.74.127])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 938BA4CD;\n\tWed, 24 Jul 2024 15:12:42 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"j4MdXJ+3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1721826762;\n\tbh=sx5fmhmlrKjv2SO2oHSAQbEttgdToUWvbm24b9N1FM0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=j4MdXJ+3b82XM7NF87HrfHDNq/5pOgQPLX6RBFlGvIOUfpIwCmECd9hmUJdQ6k/Cz\n\tluxsEylB1mIqhsVqaxRBa6Rg/r2M67fcrQU3xhBYmsb2wg14CnvacCvkUkdNPJxOM8\n\tOTt0HRvp1KNWtWI+rRYuNoFFPm9UHrtVJi1xY6+A=","Date":"Wed, 24 Jul 2024 15:13:21 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tXavier Roumegue <xavier.roumegue@oss.nxp.com>","Subject":"Re: [RFC PATCH 3/6] libcamera: yaml_parser: Increase sentinel to\n\t100k","Message-ID":"<2p5gdrbnr5o5kk66sugkr6cer53c63lng32kmumo5m54ygjrwe@bg2md2nmxdp4>","References":"<20240712052920.33396-1-umang.jain@ideasonboard.com>\n\t<20240712052920.33396-4-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240712052920.33396-4-umang.jain@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30555,"web_url":"https://patchwork.libcamera.org/comment/30555/","msgid":"<20240802223642.GD3319@pendragon.ideasonboard.com>","date":"2024-08-02T22:36:42","subject":"Re: [RFC PATCH 3/6] libcamera: yaml_parser: Increase sentinel to\n\t100k","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Jul 24, 2024 at 03:13:21PM +0200, Jacopo Mondi wrote:\n> I admin I have no idea how good or bad 100k is as a limit\n\nDo we really need 100k ?\n\n> On Fri, Jul 12, 2024 at 10:59:17AM GMT, Umang Jain wrote:\n> > From: Xavier Roumegue <xavier.roumegue@oss.nxp.com>\n> >\n> > Instead of manually increasing the limit, prepare a constexpr\n> > for maximum sentinel and use that instead.\n> >\n> > Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>\n> > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> > ---\n> >  src/libcamera/yaml_parser.cpp | 9 ++++++---\n> >  1 file changed, 6 insertions(+), 3 deletions(-)\n> >\n> > diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\n> > index 025006bc..09ed75f1 100644\n> > --- a/src/libcamera/yaml_parser.cpp\n> > +++ b/src/libcamera/yaml_parser.cpp\n> > @@ -690,6 +690,8 @@ void YamlParserContext::readValue(std::string &value, EventPtr event)\n> >  int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,\n> >  \t\t\t\t\t     const std::function<int(EventPtr event)> &parseItem)\n> >  {\n> > +\tconstexpr unsigned int maxSentinel = 100000;\n\ns/maxSentinel/kMaxSentinel/\n\nstatic constexpr ?\n\n> > +\n> >  \tyaml_event_type_t endEventType = YAML_SEQUENCE_END_EVENT;\n> >  \tif (type == YamlObject::Type::Dictionary)\n> >  \t\tendEventType = YAML_MAPPING_END_EVENT;\n> > @@ -698,7 +700,7 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,\n> >  \t * Add a safety counter to make sure we don't loop indefinitely in case\n> >  \t * the YAML file is malformed.\n> >  \t */\n> > -\tfor (unsigned int sentinel = 2000; sentinel; sentinel--) {\n> > +\tfor (unsigned int sentinel = maxSentinel; sentinel; sentinel--) {\n> >  \t\tauto evt = nextEvent();\n> >  \t\tif (!evt)\n> >  \t\t\treturn -EINVAL;\n> > @@ -711,8 +713,9 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,\n> >  \t\t\treturn ret;\n> >  \t}\n> >\n> > -\tLOG(YamlParser, Error) << \"The YAML file contains a List or Dictionary\"\n> > -\t\t\t\t  \" whose size exceeds the parser's limit (1000)\";\n> > +\tLOG(YamlParser, Error)\n> > +\t\t<< \"The YAML file contains a List or Dictionary whose size exceeds\"\n> > +\t\t<< \" the parser's limit (\" << maxSentinel << \")\";\n> >\n> >  \treturn -EINVAL;\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 4BAD7BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Aug 2024 22:37:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 85BA36337E;\n\tSat,  3 Aug 2024 00:37:05 +0200 (CEST)","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 4E6566336B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  3 Aug 2024 00:37:04 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 721883C7;\n\tSat,  3 Aug 2024 00:36:14 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"bn5KZgiD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1722638174;\n\tbh=6ms7tqyiLN+8iALrTALxImKAL3tmi7y2lQeCRFGD/3c=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=bn5KZgiDyZN2Zcv3Z5wqtLrnIJdfixGzt57umUOt8C2v9jR2pLu0kVfuK4dyJgkM/\n\txQ9gWevje+zgLqBNef+NoW1I7XxiszlwD8+UKrQmDrNJjkw75c2PLZExz6URs4Fepe\n\tvPp7B1rIPT50u5CzgJmLcXQLIZma/70u5nCMgNjk=","Date":"Sat, 3 Aug 2024 01:36:42 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Umang Jain <umang.jain@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org,\n\tXavier Roumegue <xavier.roumegue@oss.nxp.com>","Subject":"Re: [RFC PATCH 3/6] libcamera: yaml_parser: Increase sentinel to\n\t100k","Message-ID":"<20240802223642.GD3319@pendragon.ideasonboard.com>","References":"<20240712052920.33396-1-umang.jain@ideasonboard.com>\n\t<20240712052920.33396-4-umang.jain@ideasonboard.com>\n\t<2p5gdrbnr5o5kk66sugkr6cer53c63lng32kmumo5m54ygjrwe@bg2md2nmxdp4>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<2p5gdrbnr5o5kk66sugkr6cer53c63lng32kmumo5m54ygjrwe@bg2md2nmxdp4>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]