socks4 upstream: add safety check for hostname length

This commit is contained in:
rofl0r 2021-06-25 02:55:22 +01:00
parent 7ea9f80d3f
commit 563978a3ea

View File

@ -1263,6 +1263,8 @@ connect_to_upstream_proxy(struct conn_s *connptr, struct request_s *request)
memcpy(&buff[4], "\0\0\0\1" /* socks4a fake ip */ memcpy(&buff[4], "\0\0\0\1" /* socks4a fake ip */
"\0" /* user */, 5); "\0" /* user */, 5);
len = strlen(request->host); len = strlen(request->host);
if(len>255)
return -1;
memcpy(&buff[9], request->host, len+1); memcpy(&buff[9], request->host, len+1);
if (9+len+1 != safe_write(connptr->server_fd, buff, 9+len+1)) if (9+len+1 != safe_write(connptr->server_fd, buff, 9+len+1))
return -1; return -1;