aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcamera
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-08-16 00:32:13 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-08-21 21:47:18 +0300
commitdc688f1d8869798d5e856810bcdd55a22968a443 (patch)
tree9c7016119cd468f8c0cf06a620a012039a2fac57 /src/libcamera
parent7615f58f9b7ee6cd1a858a86e53668406e9efa11 (diff)
libcamera: yaml_parser: Fix bounds checking for 16-bit YamlObject::get()
The YamlObject::get() function specializations for 16-bit integers cast the return value of strto(u)l() to a 16-bit integer, rendering the bounds checking useless. Fix them. Fixes: c7d260c03abd ("libcamera: yaml_parser: Add get() specializations for 16-bit integers") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera')
-rw-r--r--src/libcamera/yaml_parser.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp
index 9162e225..f928b723 100644
--- a/src/libcamera/yaml_parser.cpp
+++ b/src/libcamera/yaml_parser.cpp
@@ -143,7 +143,7 @@ std::optional<int16_t> YamlObject::get() const
char *end;
errno = 0;
- int16_t value = std::strtol(value_.c_str(), &end, 10);
+ long value = std::strtol(value_.c_str(), &end, 10);
if ('\0' != *end || errno == ERANGE ||
value < std::numeric_limits<int16_t>::min() ||
@@ -176,7 +176,7 @@ std::optional<uint16_t> YamlObject::get() const
char *end;
errno = 0;
- uint16_t value = std::strtoul(value_.c_str(), &end, 10);
+ unsigned long value = std::strtoul(value_.c_str(), &end, 10);
if ('\0' != *end || errno == ERANGE ||
value < std::numeric_limits<uint16_t>::min() ||

Privacy Policy