diff options
author | Andy Polyakov <appro@openssl.org> | 2017-03-01 21:28:05 +0100 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2017-03-02 16:28:54 +0100 |
commit | 3e49ee23eab5c3fa57d14dc5f82f50cbea718322 (patch) | |
tree | 5e1035b282a65568d3341a1952ede257224562ae /crypto | |
parent | ea750b59297a7be5ed23d9ae579a3d69b6491c2c (diff) |
bio/b_addr.c: omit private hstrerror.
Private hstrerror was introduced to address linking problem on HP-UX,
but truth be told conemporary systems, HP-UX included, wouldn't come
to that call, they would use getaddrinfo and gai_strerror, while
gethostbyname and h_errno are there to serve legacy systems. Since
legacy systems are naturally disappearing breed, we can as well just
let user interpret number.
GH#2816
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bio/b_addr.c | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c index 0f1900db9e..51a27d5b76 100644 --- a/crypto/bio/b_addr.c +++ b/crypto/bio/b_addr.c @@ -18,30 +18,6 @@ #include <internal/thread_once.h> #include <ctype.h> -#ifdef _HPUX_SOURCE -static const char *ossl_hstrerror(int herr) -{ - switch (herr) { - case -1: - return strerror(errno); - case 0: - return "No error"; - case HOST_NOT_FOUND: - return "Host not found"; - case NO_DATA: /* NO_ADDRESS is a synonym */ - return "No data"; - case NO_RECOVERY: - return "Non recoverable error"; - case TRY_AGAIN: - return "Try again"; - default: - break; - } - return "unknown error"; -} -# define hstrerror(e) ossl_hstrerror(e) -#endif - CRYPTO_RWLOCK *bio_lookup_lock; static CRYPTO_ONCE bio_lookup_init = CRYPTO_ONCE_STATIC_INIT; @@ -688,9 +664,10 @@ int BIO_lookup(const char *host, const char *service, return 0; if (1) { - int gai_ret = 0; #ifdef AI_PASSIVE + int gai_ret = 0; struct addrinfo hints; + memset(&hints, 0, sizeof hints); hints.ai_family = family; @@ -780,8 +757,18 @@ int BIO_lookup(const char *host, const char *service, if (he == NULL) { #ifndef OPENSSL_SYS_WINDOWS - BIOerr(BIO_F_BIO_LOOKUP, ERR_R_SYS_LIB); - ERR_add_error_data(1, hstrerror(h_errno)); + /* + * This might be misleading, because h_errno is used as if + * it was errno. To minimize mixup add 1000. Underlying + * reason for this is that hstrerror is declared obsolete, + * not to mention that a) h_errno is not always guaranteed + * to be meanigless; b) hstrerror can reside in yet another + * library, linking for sake of hstrerror is an overkill; + * c) this path is not executed on contemporary systems + * anyway [above getaddrinfo/gai_strerror is]. We just let + * system administrator figure this out... + */ + SYSerr(SYS_F_GETHOSTBYNAME, 1000 + h_errno); #else SYSerr(SYS_F_GETHOSTBYNAME, WSAGetLastError()); #endif @@ -830,8 +817,7 @@ int BIO_lookup(const char *host, const char *service, if (se == NULL) { #ifndef OPENSSL_SYS_WINDOWS - BIOerr(BIO_F_BIO_LOOKUP, ERR_R_SYS_LIB); - ERR_add_error_data(1, hstrerror(h_errno)); + SYSerr(SYS_F_GETSERVBYNAME, errno); #else SYSerr(SYS_F_GETSERVBYNAME, WSAGetLastError()); #endif |