[libcamera-devel] libcamera: yaml: Increase the YAML parser limit
diff mbox series

Message ID 20230725090316.29758-1-naush@raspberrypi.com
State Accepted
Commit 5322b7ba611f6e76a7e80327de5d86acd36dd078
Headers show
Series
  • [libcamera-devel] libcamera: yaml: Increase the YAML parser limit
Related show

Commit Message

Naushir Patuck July 25, 2023, 9:03 a.m. UTC
Increase the maximum list size to 2000 elements. This allows, for
example, larger lens shading config structures to be parsed correctly
without throwing any errors.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/libcamera/yaml_parser.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham July 25, 2023, 9:06 a.m. UTC | #1
Quoting Naushir Patuck via libcamera-devel (2023-07-25 10:03:16)
> Increase the maximum list size to 2000 elements. This allows, for
> example, larger lens shading config structures to be parsed correctly
> without throwing any errors.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/libcamera/yaml_parser.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp
> index 153a6d53c3f9..bf21141e20bb 100644
> --- a/src/libcamera/yaml_parser.cpp
> +++ b/src/libcamera/yaml_parser.cpp
> @@ -676,7 +676,7 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,
>          * Add a safety counter to make sure we don't loop indefinitely in case
>          * the YAML file is malformed.
>          */
> -       for (unsigned int sentinel = 1000; sentinel; sentinel--) {
> +       for (unsigned int sentinel = 2000; sentinel; sentinel--) {
>                 auto evt = nextEvent();
>                 if (!evt)
>                         return -EINVAL;
> -- 
> 2.34.1
>
Laurent Pinchart July 27, 2023, 9:32 p.m. UTC | #2
On Tue, Jul 25, 2023 at 10:06:54AM +0100, Kieran Bingham via libcamera-devel wrote:
> Quoting Naushir Patuck via libcamera-devel (2023-07-25 10:03:16)
> > Increase the maximum list size to 2000 elements. This allows, for
> > example, larger lens shading config structures to be parsed correctly
> > without throwing any errors.
> > 
> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

We should improve this at some point, as bumping the limit from a random
value to a higher random value doesn't seem to be a great future-proof
option :-) For now,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> > ---
> >  src/libcamera/yaml_parser.cpp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp
> > index 153a6d53c3f9..bf21141e20bb 100644
> > --- a/src/libcamera/yaml_parser.cpp
> > +++ b/src/libcamera/yaml_parser.cpp
> > @@ -676,7 +676,7 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,
> >          * Add a safety counter to make sure we don't loop indefinitely in case
> >          * the YAML file is malformed.
> >          */
> > -       for (unsigned int sentinel = 1000; sentinel; sentinel--) {
> > +       for (unsigned int sentinel = 2000; sentinel; sentinel--) {
> >                 auto evt = nextEvent();
> >                 if (!evt)
> >                         return -EINVAL;

Patch
diff mbox series

diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp
index 153a6d53c3f9..bf21141e20bb 100644
--- a/src/libcamera/yaml_parser.cpp
+++ b/src/libcamera/yaml_parser.cpp
@@ -676,7 +676,7 @@  int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,
 	 * Add a safety counter to make sure we don't loop indefinitely in case
 	 * the YAML file is malformed.
 	 */
-	for (unsigned int sentinel = 1000; sentinel; sentinel--) {
+	for (unsigned int sentinel = 2000; sentinel; sentinel--) {
 		auto evt = nextEvent();
 		if (!evt)
 			return -EINVAL;