Hello,

let me suggest the following fix for the present problem.

It is standard technique and I have used it with success
in other packages, but be warned that I do not, and will
not begin using Macro$oft systems to test this, so I do
not know if the compiled executable indeed does work.
I do know that it compiles perfectly well!

Also, I will listen, should the patch not be successful,
and the failure be reported back to this bug tracker.


Good luck,
-- 
Mats Erik Andersson, fil. dr

2459 41E9 C420 3F6D F68B  2E88 F768 4541 F25B 5D41

Abonnerar på: debian-mentors, debian-devel-games, debian-perl,
              debian-ipv6, debian-qa
Description: Replace gethostbyname(3) by getaddrinfo(3).
 The indicated change of library routine produces a robuster
 resolver code. This is a standard technique, and also
 prevents an environment variable "RES_OPTIONS=inet6",
 or an entry "options inet6" in "/etc/resolv.conf, from
 disturbing gethostbyname(), as these options will make
 the returned hostentry list contain only IPv6 addresses.
Author: Mats Erik Andersson <deb...@gisladisker.se>
Forwarded: no
X-Comment: Untested in a productive network.
Last-Update: 2010-06-09
--- pptp-linux-1.7.2/pptp.c.orig	2008-05-14 08:33:55.000000000 +0200
+++ pptp-linux-1.7.2/pptp.c	2010-06-09 23:27:36.000000000 +0200
@@ -423,19 +423,27 @@
 /*** get the ipaddress coming from the command line ***************************/
 struct in_addr get_ip_address(char *name)
 {
+    int rc;
     struct in_addr retval;
-    struct hostent *host = gethostbyname(name);
-    if (host == NULL) {
-        if (h_errno == HOST_NOT_FOUND)
-            fatal("gethostbyname '%s': HOST NOT FOUND", name);
-        else if (h_errno == NO_ADDRESS)
-            fatal("gethostbyname '%s': NO IP ADDRESS", name);
-        else
-            fatal("gethostbyname '%s': name server error", name);
-    }
-    if (host->h_addrtype != AF_INET)
-        fatal("Host '%s' has non-internet address", name);
-    memcpy(&retval.s_addr, host->h_addr, sizeof(retval.s_addr));
+    struct addrinfo hints, *ai;
+
+    memset(&hints, '\0', sizeof(hints));
+    hints.ai_family = AF_INET;
+#if defined(__linux__) || defined(__FreeBSD__)
+    hints.ai_flags = AI_ADDRCONFIG;     /* Unknown in OpenBSD. */
+#endif
+
+    if ( (rc = getaddrinfo(name, NULL, &hints, &ai)) )
+        fatal("getaddrinfo(): %s", gai_strerror(rc));
+
+    if (ai->ai_addr->sa_family != AF_INET)       /* Should never happen. */
+        fatal("Host '%s' possesses no IPv4 address", name);
+
+    memcpy(&retval.s_addr,
+            &(((struct sockaddr_in *) ai->ai_addr)->sin_addr.s_addr),
+            sizeof(retval.s_addr));
+    freeaddrinfo(ai);
+
     return retval;
 }
 

Attachment: signature.asc
Description: Digital signature

Reply via email to