On Sun, Aug 24, 2003 at 10:43:36PM -0000, [EMAIL PROTECTED] wrote:
...
>   +#if APR_HAVE_IPV6
>   +            int v6only_setting;
>   +            /* If we are trying to bind to 0.0.0.0 and the previous listener
>   +             * was :: on the same port and in turn that socket does not have
>   +             * the IPV6_V6ONLY flag set; we must skip the current attempt to
>   +             * listen (which would generate an error). IPv4 will be handled
>   +             * on the established IPv6 socket.
>   +             */
>   +            if (previous != NULL &&
>   +                lr->bind_addr->family == APR_INET &&
>   +                *((in_addr_t *)lr->bind_addr->ipaddr_ptr) == INADDR_ANY &&
>   +                lr->bind_addr->port == previous->bind_addr->port &&
>   +                previous->bind_addr->family == APR_INET6 &&
>   +                IN6_IS_ADDR_UNSPECIFIED(
>   +                        (struct in6_addr*)(previous->bind_addr->ipaddr_ptr)) &&

This doesn't compile on some older Unixes since in_addr_t is a recent
invention; the casts aren't really necessary anyway.

Also the below conditional looks dubious - previous->bind_addr should be
lr->bind_addr, and the lr->next family is never checked?  Attached a
patch which looks logically right and fixes the compile error, not
tested though - can you test it?

>                else {
>   +#if APR_HAVE_IPV6
>   +                /* If we tried to bind to ::, and the next listener is
>   +                 * on 0.0.0.0 with the same port, don't give a fatal
>   +                 * error. The user will still get a warning from make_sock
>   +                 * though.
>   +                 */
>   +                if (lr->next != NULL && lr->bind_addr->family == APR_INET6 &&
>   +                    IN6_IS_ADDR_UNSPECIFIED(
>   +                        (struct in6_addr*)(previous->bind_addr->ipaddr_ptr)) &&
>   +                    lr->bind_addr->port == lr->next->bind_addr->port &&
>   +                    *((in_addr_t *)lr->next->bind_addr->ipaddr_ptr)
>   +                    == INADDR_ANY) {

Index: listen.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/listen.c,v
retrieving revision 1.90
diff -u -r1.90 listen.c
--- listen.c    24 Aug 2003 22:43:36 -0000      1.90
+++ listen.c    25 Aug 2003 08:14:39 -0000
@@ -355,11 +355,11 @@
              */
             if (previous != NULL &&
                 lr->bind_addr->family == APR_INET &&
-                *((in_addr_t *)lr->bind_addr->ipaddr_ptr) == INADDR_ANY &&
+                lr->bind_addr->sa.sin.sin_addr.s_addr == INADDR_ANY &&
                 lr->bind_addr->port == previous->bind_addr->port &&
                 previous->bind_addr->family == APR_INET6 &&
                 IN6_IS_ADDR_UNSPECIFIED(
-                        (struct in6_addr*)(previous->bind_addr->ipaddr_ptr)) &&
+                    previous->bind_addr->sa.sin6.sin6_addr.s6_addr) &&
                 apr_socket_opt_get(previous->sd, APR_IPV6_V6ONLY,
                                    &v6only_setting) == APR_SUCCESS &&
                 v6only_setting == 0) {
@@ -382,10 +382,10 @@
                  */
                 if (lr->next != NULL && lr->bind_addr->family == APR_INET6 &&
                     IN6_IS_ADDR_UNSPECIFIED(
-                        (struct in6_addr*)(previous->bind_addr->ipaddr_ptr)) &&
+                        lr->bind_addr->sa.sin6.sin6_addr.s6_addr) &&
                     lr->bind_addr->port == lr->next->bind_addr->port &&
-                    *((in_addr_t *)lr->next->bind_addr->ipaddr_ptr)
-                    == INADDR_ANY) {
+                    lr->next->bind_addr->family == APR_INET && 
+                    lr->next->bind_addr->sa.sin.sin_addr.s_addr == INADDR_ANY) {
 
                     /* Remove the current listener from the list */
                     if (previous) {

Reply via email to