Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
add missing typecast for isxdigit() call in bgpd
To:
tech@openbsd.org
Date:
Mon, 18 Mar 2024 11:20:37 +0100

Download raw body.

Thread
The isxdigit() checks in str2key() miss the required (unsigned char)
typecast. Also add int to the unsigned variable i.

Warning from gcc reported by goshhhy on github.
-- 
:wq Claudio

Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
diff -u -p -r1.455 parse.y
--- parse.y	16 Aug 2023 08:26:35 -0000	1.455
+++ parse.y	18 Mar 2024 10:15:13 -0000
@@ -4989,7 +4989,7 @@ expand_rule(struct filter_rule *rule, st
 int
 str2key(char *s, char *dest, size_t max_len)
 {
-	unsigned	i;
+	unsigned int	i;
 	char		t[3];
 
 	if (strlen(s) / 2 > max_len) {
@@ -5006,7 +5006,8 @@ str2key(char *s, char *dest, size_t max_
 		t[0] = s[2*i];
 		t[1] = s[2*i + 1];
 		t[2] = 0;
-		if (!isxdigit(t[0]) || !isxdigit(t[1])) {
+		if (!isxdigit((unsigned char)t[0]) ||
+		    !isxdigit((unsigned char)t[1])) {
 			yyerror("key must be specified in hex");
 			return (-1);
 		}