[cups.bugs] [MOD] STR #2621: Listen *:631 doesn't work on system without getaddrinfo()

Bryan Henderson bryanh at giraffe-data.com
Thu Dec 6 19:10:56 PST 2007


DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

I think there's something wrong with httpAddrGetList() in
cups/http-addrlist.c.  I can't say I was able to follow all the
twists and turns in this 450 line ifdef'ed function, but I believe
on a system that does not have getaddrinfo(), it does not properly
handle a hostname == NULL argument.  I believe that is supposed to
mean, "any host," and should result in an address list with an "any
host" entry in it, but instead httpAddrGetList() returns an empty
list.  For me, 'Listen *:631' generated a syntax error as a result.
I fixed it with this:

diff --unif --new-file --rec cups-1.3.4/cups/http-addrlist.c
cups/cups/http-add\
rlist.c
--- cups-1.3.4/cups/http-addrlist.c     2007-07-11 21:46:42.000000000
+0000
+++ cups/cups/http-addrlist.c   2007-11-18 22:13:22.000000000 +0000
@@ -314,7 +314,6 @@
       freeaddrinfo(results);
     }
 #else
-    if (hostname)
     {
       int              i;              /* Looping vars */
       unsigned         ip[4];          /* IPv4 address components */
@@ -347,6 +346,15 @@
       else
        return (NULL);

+      if (!hostname) {
+        first = (http_addrlist_t *)calloc(1, sizeof(http_addrlist_t));
+        if (!first)
+          return (NULL);
+
+        first->addr.ipv4.sin_family = AF_INET;
+        first->addr.ipv4.sin_addr.s_addr = htonl(INADDR_ANY);
+        first->addr.ipv4.sin_port = htons(portnum);
+      } else {
      /*
       * This code is needed because some operating systems have a
       * buggy implementation of gethostbyname() that does not support
@@ -430,6 +438,7 @@
        }
       }
     }
+    }
 #endif /* HAVE_GETADDRINFO */
   }

Link: http://www.cups.org/str.php?L2621
Version: 1.3.4





More information about the cups mailing list