From dc688f1d8869798d5e856810bcdd55a22968a443 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 16 Aug 2022 00:32:13 +0300 Subject: 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 Reviewed-by: Paul Elder Reviewed-by: Jacopo Mondi --- src/libcamera/yaml_parser.cpp | 4 ++-- 1 file 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 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::min() || @@ -176,7 +176,7 @@ std::optional 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::min() || -- cgit v1.2.1