cli: Validate hex color length
This commit is contained in:
parent
8619d77445
commit
139a9c4010
1 changed files with 9 additions and 6 deletions
3
cli.cpp
3
cli.cpp
|
|
@ -269,6 +269,8 @@ bool ParseColors(std::string colors_string, DeviceOptions *options)
|
||||||
|
|
||||||
/* swy: (B) no luck, try interpreting it as an hexadecimal number instead */
|
/* swy: (B) no luck, try interpreting it as an hexadecimal number instead */
|
||||||
if (!parsed)
|
if (!parsed)
|
||||||
|
{
|
||||||
|
if (color.length() == 6)
|
||||||
{
|
{
|
||||||
const char *colorptr = color.c_str(); char *endptr = NULL;
|
const char *colorptr = color.c_str(); char *endptr = NULL;
|
||||||
|
|
||||||
|
|
@ -279,6 +281,7 @@ bool ParseColors(std::string colors_string, DeviceOptions *options)
|
||||||
if (colorptr != endptr && endptr && *endptr == '\0')
|
if (colorptr != endptr && endptr && *endptr == '\0')
|
||||||
parsed = true;
|
parsed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* swy: we got it, save the 32-bit integer as a tuple of three RGB bytes */
|
/* swy: we got it, save the 32-bit integer as a tuple of three RGB bytes */
|
||||||
if (parsed)
|
if (parsed)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue