Skip to content

Commit 144f4bb

Browse files
committed
Addressed Copilot review comments
1 parent ce05d2b commit 144f4bb

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/client/client.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,14 @@ static WC_INLINE void clu_build_addr(SOCKADDR_IN4_T* addr, SOCKADDR_IN6_T* ipv6,
152152
const char* cp;
153153

154154
/* Validate hostname: only allow characters valid in DNS names
155-
* (RFC 1123) to prevent shell injection via popen(). */
155+
* (RFC 1123) to prevent shell injection via popen().
156+
* Use explicit ASCII ranges instead of isalnum() to avoid
157+
* locale-dependent behavior. */
156158
for (cp = peer; *cp != '\0'; cp++) {
157-
if (!isalnum((unsigned char)*cp) &&
158-
*cp != '.' && *cp != '-') {
159+
if (!((*cp >= 'A' && *cp <= 'Z') ||
160+
(*cp >= 'a' && *cp <= 'z') ||
161+
(*cp >= '0' && *cp <= '9') ||
162+
*cp == '.' || *cp == '-')) {
159163
err_sys("invalid character in hostname");
160164
return;
161165
}

0 commit comments

Comments
 (0)