From: Andy Polyakov Date: Thu, 26 Nov 2009 20:56:05 +0000 (+0000) Subject: bss_dgram.c: re-fix BIO_CTRL_DGRAM_GET_PEER (from HEAD). X-Git-Tag: OpenSSL_1_0_0-beta5~75 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b9b23603f742e8d562c054eb5a88a6681003c78;p=openssl bss_dgram.c: re-fix BIO_CTRL_DGRAM_GET_PEER (from HEAD). --- diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index f63f1bf6fb..fa886af557 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -565,21 +565,23 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) } break; case BIO_CTRL_DGRAM_GET_PEER: - to = (struct sockaddr *) ptr; - switch (to->sa_family) + switch (data->peer.sa.sa_family) { case AF_INET: - memcpy(to,&data->peer,(ret=sizeof(data->peer.sa_in))); + ret=sizeof(data->peer.sa_in); break; #if OPENSSL_USE_IPV6 case AF_INET6: - memcpy(to,&data->peer,(ret=sizeof(data->peer.sa_in6))); + ret=sizeof(data->peer.sa_in6); break; #endif default: - memcpy(to,&data->peer,(ret=sizeof(data->peer.sa))); + ret=sizeof(data->peer.sa); break; } + if (num==0 || num>ret) + num=ret; + memcpy(ptr,&data->peer,(ret=num)); break; case BIO_CTRL_DGRAM_SET_PEER: to = (struct sockaddr *) ptr;