Use WSAGetLastError() on windows
authorKurt Roeckx <kurt@roeckx.be>
Thu, 4 Feb 2016 14:20:26 +0000 (15:20 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Thu, 4 Feb 2016 15:05:59 +0000 (16:05 +0100)
Windows doesn't have h_error or hstrerror()

Reviewed-by: Richard Levitte <levitte@openssl.org>
MR: #1848

crypto/bio/b_addr.c
crypto/err/err.c
include/openssl/err.h

index 8f94fe8ffb118a663d1bb9a4097659b34990b310..61714e5602aaf746d0874fb8706ec0d5aa8a51f6 100644 (file)
@@ -715,8 +715,12 @@ int BIO_lookup(const char *host, const char *service,
             he = gethostbyname(host);
 
             if (he == NULL) {
+#ifndef OPENSSL_SYS_WINDOWS
                 BIOerr(BIO_F_BIO_LOOKUP, ERR_R_SYS_LIB);
                 ERR_add_error_data(1, hstrerror(h_errno));
+#else
+                SYSerr(SYS_F_GETHOSTBYNAME, WSAGetLastError());
+#endif
                 ret = 0;
                 goto err;
             }
@@ -747,8 +751,12 @@ int BIO_lookup(const char *host, const char *service,
                 se = getservbyname(service, proto);
 
                 if (se == NULL) {
+#ifndef OPENSSL_SYS_WINDOWS
                     BIOerr(BIO_F_BIO_LOOKUP, ERR_R_SYS_LIB);
                     ERR_add_error_data(1, hstrerror(h_errno));
+#else
+                    SYSerr(SYS_F_GETSERVBYNAME, WSAGetLastError());
+#endif
                     goto err;
                 }
             } else {
index 6cb582debee0d4a87613d3cff92d30acfae78a46..64f8adc46d5d21a4ddb5d1e8362bcc313b6754ed 100644 (file)
@@ -178,6 +178,7 @@ static ERR_STRING_DATA ERR_str_functs[] = {
     {ERR_PACK(0, SYS_F_SETSOCKOPT, 0), "setsockopt"},
     {ERR_PACK(0, SYS_F_GETSOCKOPT, 0), "getsockopt"},
     {ERR_PACK(0, SYS_F_GETSOCKNAME, 0), "getsockname"},
+    {ERR_PACK(0, SYS_F_GETHOSTBYNAME, 0), "gethostbyname"},
     {0, NULL},
 };
 
index 370763c35ff0e2105574083c6f785abd3d34c9f6..8baf6b7a13904f76b2bedc21876f55a326522743 100644 (file)
@@ -262,6 +262,7 @@ typedef struct err_state_st {
 # define SYS_F_SETSOCKOPT        14
 # define SYS_F_GETSOCKOPT        15
 # define SYS_F_GETSOCKNAME       16
+# define SYS_F_GETHOSTBYNAME     17
 
 /* reasons */
 # define ERR_R_SYS_LIB   ERR_LIB_SYS/* 2 */