From bf4056a2c6e1cdbebe105cd4e80d2843e0030093 Mon Sep 17 00:00:00 2001 From: progandy Date: Thu, 4 Aug 2016 14:37:54 +0200 Subject: common: use strtoul in parse_color to avoid clamp Some implementations of strtol may clamp the values to LONG_MAX instead of wrapping around to negative values, so use strtoul instead to parse colors. --- common/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/util.c b/common/util.c index 86120769..f0b0fdf0 100644 --- a/common/util.c +++ b/common/util.c @@ -104,7 +104,7 @@ uint32_t parse_color(const char *color) { sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color); return 0xFFFFFFFF; } - uint32_t res = (uint32_t)strtol(color + 1, NULL, 16); + uint32_t res = (uint32_t)strtoul(color + 1, NULL, 16); if (strlen(color) == 7) { res = (res << 8) | 0xFF; } -- cgit v1.2.3