Since IPv6 support was added, in dgram_write() the size of data->peer cannot be 
used for sendto() anymore. The union has the size of sockaddr_in6 when IPv6 is 
enabled and therefore sendto() always fails with Invalid Argument when only 
IPv4 is used. It should be either the size of sockaddr_in or sockaddr_in6, 
depending on the protocol.

Regards,
Robin


Index: crypto/bio/bss_dgram.c
===================================================================
RCS file: /v/openssl/cvs/openssl/crypto/bio/bss_dgram.c,v
retrieving revision 1.7.2.21
diff -u -r1.7.2.21 bss_dgram.c
--- crypto/bio/bss_dgram.c      26 Nov 2009 20:56:05 -0000      1.7.2.21
+++ crypto/bio/bss_dgram.c      27 Nov 2009 14:29:03 -0000
@@ -329,16 +329,22 @@
 static int dgram_write(BIO *b, const char *in, int inl)
        {
        int ret;
+       socklen_t peerlen;
        bio_dgram_data *data = (bio_dgram_data *)b->ptr;
        clear_socket_error();
 
+       if (data->peer.sa.sa_family == AF_INET6)
+               peerlen = sizeof(data->peer.sa_in6);
+       else
+               peerlen = sizeof(data->peer.sa_in);
+
        if ( data->connected )
                ret=writesocket(b->num,in,inl);
        else
 #if defined(NETWARE_CLIB) && defined(NETWARE_BSDSOCK)
-               ret=sendto(b->num, (char *)in, inl, 0, &data->peer.sa, 
sizeof(data->peer));
+               ret=sendto(b->num, (char *)in, inl, 0, &data->peer.sa, peerlen);
 #else
-               ret=sendto(b->num, in, inl, 0, &data->peer.sa, 
sizeof(data->peer));
+               ret=sendto(b->num, in, inl, 0, &data->peer.sa, peerlen);
 #endif
 
        BIO_clear_retry_flags(b);



Attachment: peerlen.patch
Description: Binary data

Reply via email to