From: Jason A. Donenfeld Date: Thu, 31 Jan 2019 01:03:10 +0000 (+0100) Subject: highlighter: when subtracting char, cast to unsigned X-Git-Tag: v1.0.20191226~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e58a0525edd39f18c6ebdae3e021a18ed98ba59;p=thirdparty%2Fwireguard-tools.git highlighter: when subtracting char, cast to unsigned Windows. Signed-off-by: Jason A. Donenfeld --- diff --git a/contrib/highlighter/highlighter.c b/contrib/highlighter/highlighter.c index 171a84c..1913e35 100644 --- a/contrib/highlighter/highlighter.c +++ b/contrib/highlighter/highlighter.c @@ -166,9 +166,9 @@ static bool is_valid_uint(string_span_t s, bool support_hex, uint64_t min, uint6 if (support_hex && s.len > 2 && s.s[0] == '0' && s.s[1] == 'x') { for (size_t i = 2; i < s.len; ++i) { - if (s.s[i] - '0' < 10) + if ((unsigned)s.s[i] - '0' < 10) val = 16 * val + (s.s[i] - '0'); - else if ((s.s[i] | 32) - 'a' < 6) + else if (((unsigned)s.s[i] | 32) - 'a' < 6) val = 16 * val + (s.s[i] | 32) - 'a' + 10; else return false;