aboutsummaryrefslogtreecommitdiff
path: root/crypto/bio
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-02-04 17:17:36 +0100
committerRichard Levitte <levitte@openssl.org>2016-02-04 17:33:28 +0100
commited03c46134b1ebfcbee937c74e7f4517893be1fd (patch)
treeb8cbc8a6414bf2f6836c44104d20307ebbb25ff2 /crypto/bio
parentb31feae6de975f391bb9688231079ee745e94d5d (diff)
downloadopenssl-ed03c46134b1ebfcbee937c74e7f4517893be1fd.zip
openssl-ed03c46134b1ebfcbee937c74e7f4517893be1fd.tar.gz
openssl-ed03c46134b1ebfcbee937c74e7f4517893be1fd.tar.bz2
Make sure getaddrinfo and getnameinfo works as intended on Windows
Both getaddrinfo() and getnameinfo() have to be preceeded with a call to BIO_sock_init(). Also, make sure to give gai_strerror() the actual error code. Reviewed-by: Stephen Henson <steve@openssl.org>
Diffstat (limited to 'crypto/bio')
-rw-r--r--crypto/bio/b_addr.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c
index 61714e5..20cb66d 100644
--- a/crypto/bio/b_addr.c
+++ b/crypto/bio/b_addr.c
@@ -214,6 +214,9 @@ unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap)
static int addr_strings(const BIO_ADDR *ap, int numeric,
char **hostname, char **service)
{
+ if (BIO_sock_init() != 1)
+ return 0;
+
if (1) {
#ifdef AI_PASSIVE
int ret = 0;
@@ -633,7 +636,11 @@ int BIO_lookup(const char *host, const char *service,
}
#endif
+ if (BIO_sock_init() != 1)
+ return 0;
+
if (1) {
+ int gai_ret = 0;
#ifdef AI_PASSIVE
struct addrinfo hints;
@@ -655,7 +662,7 @@ int BIO_lookup(const char *host, const char *service,
/* Note that |res| SHOULD be a 'struct addrinfo **' thanks to
* macro magic in bio_lcl.h
*/
- switch (getaddrinfo(host, service, &hints, res)) {
+ switch ((gai_ret = getaddrinfo(host, service, &hints, res))) {
# ifdef EAI_SYSTEM
case EAI_SYSTEM:
SYSerr(SYS_F_GETADDRINFO, get_last_socket_error());
@@ -667,7 +674,7 @@ int BIO_lookup(const char *host, const char *service,
break;
default:
BIOerr(BIO_F_BIO_LOOKUP, ERR_R_SYS_LIB);
- ERR_add_error_data(1, gai_strerror(ret));
+ ERR_add_error_data(1, gai_strerror(gai_ret));
break;
}
} else {