[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Handle return value from getaddrinfo properly



Update of /home/or/cvsroot/tor/src/common
In directory moria.mit.edu:/tmp/cvs-serv28763/src/common

Modified Files:
	compat.c 
Log Message:
Handle return value from getaddrinfo properly

Index: compat.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/compat.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- compat.c	3 Feb 2005 21:31:04 -0000	1.33
+++ compat.c	3 Feb 2005 23:13:36 -0000	1.34
@@ -513,14 +513,15 @@
     memset(&hints, 0, sizeof(hints));
     hints.ai_family = PF_INET;
     hints.ai_socktype = SOCK_STREAM;
-    err = getaddrinfo(name, NULL, &hints, &res);
+    err = getaddrinfo(name, NULL, NULL, &res);
     if (!err) {
       for (res_p = res; res_p; res_p = res_p->ai_next) {
-        if (res_p->ai_family == PF_INET &&
-            res_p->ai_addrlen == 4) {
-          memcpy(addr, res_p->ai_addr, 4);
+        if (res_p->ai_family == AF_INET) {
+          struct sockaddr_in *sin = (struct sockaddr_in *)res_p->ai_addr;
+          memcpy(addr, &sin->sin_addr, 4);
           freeaddrinfo(res);
           return 0;
+        } else {
         }
       }
       return -1;