diff options
author | David du Colombier <0intro@gmail.com> | 2012-09-11 17:11:44 +0200 |
---|---|---|
committer | David du Colombier <0intro@gmail.com> | 2012-09-11 17:11:44 +0200 |
commit | 6f568da64e625a1e517de6147058888515a0ccb7 (patch) | |
tree | f8ba7cec21ccda74da51ea4143a428453fc4d38f /src | |
parent | d4ccb0a943fb312d949726827d4e4e71e6a7a0bb (diff) | |
download | plan9port-6f568da64e625a1e517de6147058888515a0ccb7.tar.gz plan9port-6f568da64e625a1e517de6147058888515a0ccb7.tar.bz2 plan9port-6f568da64e625a1e517de6147058888515a0ccb7.zip |
lib9/p9dialparse: fix segfault on gethostbyname
In some situations, gethostbyname can
return an empty address list.
R=rsc
http://codereview.appspot.com/6443097
Diffstat (limited to 'src')
-rw-r--r-- | src/lib9/_p9dialparse.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib9/_p9dialparse.c b/src/lib9/_p9dialparse.c index 4ff4d3cc..2cc23574 100644 --- a/src/lib9/_p9dialparse.c +++ b/src/lib9/_p9dialparse.c @@ -109,7 +109,7 @@ p9dialparse(char *addr, char **pnet, char **punix, void *phost, int *pport) if(strcmp(host, "*") == 0){ ss->ss_family = AF_INET6; ((struct sockaddr_in6*)ss)->sin6_addr = in6addr_any; - }else if((he = gethostbyname(host)) != nil){ + }else if((he = gethostbyname(host)) != nil && he->h_addr_list[0] != nil){ ss->ss_family = he->h_addrtype; switch(ss->ss_family){ case AF_INET: |