tlib9/p9dialparse: fix segfault on gethostbyname - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 6f568da64e625a1e517de6147058888515a0ccb7
 (DIR) parent d4ccb0a943fb312d949726827d4e4e71e6a7a0bb
 (HTM) Author: David du Colombier <0intro@gmail.com>
       Date:   Tue, 11 Sep 2012 17:11:44 +0200
       
       lib9/p9dialparse: fix segfault on gethostbyname
       
       In some situations, gethostbyname can
       return an empty address list.
       
       R=rsc
       http://codereview.appspot.com/6443097
       
       Diffstat:
         M src/lib9/_p9dialparse.c             |       2 +-
       
       1 file changed, 1 insertion(+), 1 deletion(-)
       ---
 (DIR) diff --git a/src/lib9/_p9dialparse.c b/src/lib9/_p9dialparse.c
       t@@ -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: