Blame SOURCES/graphviz-2.34.0-lefty-getaddrinfo.patch

a2d586
diff -up graphviz-2.34.0/cmd/lefty/os/unix/io.c.orig graphviz-2.34.0/cmd/lefty/os/unix/io.c
a2d586
--- graphviz-2.34.0/cmd/lefty/os/unix/io.c.orig	2013-09-07 03:07:52.000000000 +0200
a2d586
+++ graphviz-2.34.0/cmd/lefty/os/unix/io.c	2013-10-30 17:38:59.746296595 +0100
a2d586
@@ -285,9 +285,8 @@ int IOwriteline (int ioi, char *bufp) {
a2d586
 
a2d586
 static FILE *serverconnect (char *name) {
a2d586
     char *host, *portp, buf[1024];
a2d586
-    int port;
a2d586
-    struct hostent *hp;
a2d586
-    struct sockaddr_in sin;
a2d586
+    struct addrinfo *ai;
a2d586
+    struct addrinfo hints;
a2d586
     int cfd;
a2d586
 
a2d586
     strcpy (buf, name);
a2d586
@@ -295,17 +294,18 @@ static FILE *serverconnect (char *name)
a2d586
     portp = strchr (host, '/');
a2d586
     if (*host == 0 || !portp)
a2d586
         return NULL;
a2d586
-    *portp++ = 0, port = atoi (portp);
a2d586
-    if (!(hp = gethostbyname (host)))
a2d586
-        return NULL;
a2d586
-    memset ((char *) &sin, 1, sizeof (sin));
a2d586
-    memcpy ((char *) &sin.sin_addr, hp->h_addr, hp->h_length);
a2d586
-    sin.sin_family = hp->h_addrtype;
a2d586
-    sin.sin_port = htons (port);
a2d586
-    if ((cfd = socket (hp->h_addrtype, SOCK_STREAM, 0)) < 0)
a2d586
-        return NULL;
a2d586
-    if (connect (cfd, (struct sockaddr *) &sin, sizeof (sin)) < 0)
a2d586
-        return NULL;
a2d586
+    *portp++ = 0;
a2d586
+    memset (&hints, 0, sizeof (hints));
a2d586
+    hints.ai_family = AF_UNSPEC;
a2d586
+    hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;
a2d586
+    hints.ai_socktype = SOCK_STREAM;
a2d586
+    if (getaddrinfo (host, portp, &hints, &ai))
a2d586
+        return freeaddrinfo(ai), NULL;
a2d586
+    if ((cfd = socket (ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0)
a2d586
+        return freeaddrinfo(ai), NULL;
a2d586
+    if (connect (cfd, ai->ai_addr, ai->ai_addrlen) < 0)
a2d586
+        return freeaddrinfo(ai), NULL;
a2d586
+    freeaddrinfo(ai);
a2d586
     return fdopen (cfd, "w+");
a2d586
 }
a2d586