apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: svn commit: r584634 - /apr/apr/trunk/test/testsockets.c
Date Mon, 15 Oct 2007 07:33:45 GMT
On Sun, Oct 14, 2007 at 11:07:43PM -0000, William Rowe wrote:
> Author: wrowe
> Date: Sun Oct 14 16:07:43 2007
> New Revision: 584634
> 
> URL: http://svn.apache.org/viewvc?rev=584634&view=rev
> Log:
> recvfrom() failed on most platforms with a sockaddr only
> large enough to hold an ipv6 address.  Big shock.

If that fails it's a bug in the apr_socket_recvfrom() implementation.  

There is no reason that function should fail if the *from argument 
happened to previously be representing a socket address of a different 
family to the socket from which a block is being read - it's an output 
parameter for the function.

The test case checked for exactly that happening:

http://svn.apache.org/viewvc?view=rev&revision=467600

> Modified:
>     apr/apr/trunk/test/testsockets.c
> 
> Modified: apr/apr/trunk/test/testsockets.c
> URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testsockets.c?rev=584634&r1=584633&r2=584634&view=diff
> ==============================================================================
> --- apr/apr/trunk/test/testsockets.c (original)
> +++ apr/apr/trunk/test/testsockets.c Sun Oct 14 16:07:43 2007
> @@ -103,7 +103,8 @@
>  #endif
>  }
>  
> -static void sendto_receivefrom_helper(abts_case *tc, const char *addr, int family)
> +static void sendto_receivefrom_helper(abts_case *tc, const char *addr, 
> +                                      const char *junkaddr, int family)
>  {
>      apr_status_t rv;
>      apr_socket_t *sock = NULL;
> @@ -152,7 +153,8 @@
>  
>      /* fill the "from" sockaddr with a random address to ensure that
>       * recvfrom sets it up properly. */
> -    apr_sockaddr_info_get(&from, "127.1.2.3", APR_INET, 4242, 0, p);
> +    rv = apr_sockaddr_info_get(&from, junkaddr, family, 4242, 0, p);
> +    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
>  
>      len = 80;
>      rv = apr_socket_recvfrom(from, sock, 0, recvbuf, &len);
> @@ -171,10 +173,10 @@
>  
>  static void sendto_receivefrom(abts_case *tc, void *data)
>  {
> +    sendto_receivefrom_helper(tc, "127.0.0.1",  "127.1.2.3", APR_INET);
>  #if APR_HAVE_IPV6
> -    sendto_receivefrom_helper(tc, "::1", APR_INET6);
> +    sendto_receivefrom_helper(tc, "::1", "FA0E::1234:127.1.2.3", APR_INET6);
>  #endif
> -    sendto_receivefrom_helper(tc, "127.0.0.1", APR_INET);
>  }
>  
>  static void socket_userdata(abts_case *tc, void *data)
> 

Mime
View raw message