← Commit list

2c26cea5ec

Kaixuan Li
Kaixuan Li
2026-03-30
SUCCESS Duration: 251s

Subject

socks: add assertion for hostname length in SOCKS5 connect

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/socks.c+4 -0
@@ -808,6 +808,10 @@ static CURLproxycode socks5_req1_init(struct socks_state *sx,
}
else {
const size_t hostname_len = strlen(sx->hostname);
+ /* socks5_req0_init() already rejects hostnames longer than 255 bytes, so
+ this cast to unsigned char is safe. Assert to guard against future
+ refactoring that might remove or reorder that earlier check. */
+ DEBUGASSERT(hostname_len <= 255);
desttype = 3;
destination = (const unsigned char *)sx->hostname;
destlen = (unsigned char)hostname_len; /* one byte length */