Use strrchr to ensure we split off the last colon for the service port

IPv6 addresses have colons and will produce invalid data for the getaddrinfo lookup.

Signed-off-by: Andrew Thompson <andy@fud.org.nz>
This commit is contained in:
Andrew Thompson 2011-06-29 23:48:19 +02:00 committed by Martin Sustrik
parent 543ad30e7d
commit 4f4cc73280
2 changed files with 2 additions and 1 deletions

View File

@ -2,6 +2,7 @@ Contributors
============
Alexej Lotz <alexej.lotz@arcor.de>
Andrew Thompson <andy@fud.org.nz>
Asko Kauppi <askok@dnainternet.net>
Barak Amar <barak.amar@gmail.com>
Bernd Prager <bernd@prager.ws>

View File

@ -272,7 +272,7 @@ int zmq::resolve_ip_hostname (sockaddr_storage *addr_, socklen_t *addr_len_,
const char *hostname_)
{
// Find the ':' that separates hostname name from service.
const char *delimiter = strchr (hostname_, ':');
const char *delimiter = strrchr (hostname_, ':');
if (!delimiter) {
errno = EINVAL;
return -1;