use memchr instead of strchr for checking if host is ipv6

This commit is contained in:
Marco Casaroli 2016-06-03 12:12:24 -03:00
parent e657ca40e9
commit 19e08de0e2

View File

@ -419,11 +419,11 @@ event(struct tcp_socket *tcps, void *ptr,
tcp_socket_send_str(tcps, "Host: ");
/* If we have IPv6 host, add the '[' and the ']' characters
to the host. As in rfc2732. */
if (strchr(host, ':')) {
if (memchr(host, ':', MAX_HOSTLEN)) {
tcp_socket_send_str(tcps, "[");
}
tcp_socket_send_str(tcps, host);
if (strchr(host, ':')) {
if (memchr(host, ':', MAX_HOSTLEN)) {
tcp_socket_send_str(tcps, "]");
}
tcp_socket_send_str(tcps, "\r\n");