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: c7d260c03a
("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>
This commit is contained in:
parent
7615f58f9b
commit
dc688f1d88
1 changed files with 2 additions and 2 deletions
|
@ -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() ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue