Date: Mon, 11 Jun 2012 17:57:20 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r237474 - in soc2012/exxo: . patches Message-ID: <20120611175720.73AE0106577C@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: exxo Date: Mon Jun 11 17:57:19 2012 New Revision: 237474 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=237474 Log: Adding support of getaddrinfo in openssl-1.0.1c Added: soc2012/exxo/bugnotes.txt soc2012/exxo/patches/openssl-1.0.1c-getaddrinfo.patch Added: soc2012/exxo/bugnotes.txt ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/exxo/bugnotes.txt Mon Jun 11 17:57:19 2012 (r237474) @@ -0,0 +1,14 @@ +<openssl-1.0.1c> + + TYPE conceptual error + WHERE b_sock.c:689 in BIO_get_accept_socket() + DESCRIPTION the parsing of source address is not complete when requesting IPv6 listening explicitly + (e.g "localhost::1234" leads to h="localhost:", p="1234") + AFFECTS all hosts with IPv6 syntax "::" excluding "::port" + + -------------- + + TYPE incorrect behaviour of API + WHERE b_sock.c:705 in BIO_get_accept_socket() + DESCRIPTION requesting an IPv6 listening of an host without AAAA record fallback to IPv4 + AFFECTS all hosts supporting IPv4 only Added: soc2012/exxo/patches/openssl-1.0.1c-getaddrinfo.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/exxo/patches/openssl-1.0.1c-getaddrinfo.patch Mon Jun 11 17:57:19 2012 (r237474) @@ -0,0 +1,134 @@ +diff -rup openssl-1.0.1c/crypto/bio/b_sock.c openssl-1.0.1c-working/crypto/bio/b_sock.c +--- openssl-1.0.1c/crypto/bio/b_sock.c 2012-04-16 19:43:14.000000000 +0200 ++++ openssl-1.0.1c-working/crypto/bio/b_sock.c 2012-06-10 01:09:15.000000000 +0200 +@@ -467,9 +467,60 @@ end: + #endif + } + ++int BIO_getaddrinfo(const char *hostname, const char *servname, ++ const struct addrinfo *hints, struct addrinfo **res) ++ { ++#ifdef EAI_FAMILY ++ int err; ++ const char *reason; ++ static union { void *p; ++ int (WSAAPI *f)(const char *,const char *, ++ const struct addrinfo *, ++ struct addrinfo **); ++ } p_getaddrinfo = {NULL}; ++ static union { void *p; ++ const char * (WSAAPI *f)(int); ++ } p_gai_strerror = {NULL}; ++ ++ if ((p_getaddrinfo.p=DSO_global_lookup("getaddrinfo"))!=NULL) ++ { ++ if ((err = (*p_getaddrinfo.f)(hostname,servname,hints,res))) ++ { ++ BIOerr(BIO_F_BIO_GETADDRINFO,BIO_R_BAD_HOSTNAME_LOOKUP); ++ if ((p_gai_strerror.p=DSO_global_lookup("gai_strerror"))!=NULL) ++ { ++#ifdef OPENSSL_SYS_WINDOWS /* gai_strerror is not thread-safe under Microsoft Windows */ ++ CRYPTO_w_lock(CRYPTO_LOCK_GAI_STRERROR); ++ reason = (*p_gai_strerror.f)(err); ++ CRYPTO_w_unlock(CRYPTO_LOCK_GAI_STRERROR); ++#else ++ reason = (*p_gai_strerror.f)(err); ++#endif ++ ERR_add_error_data(1, (*p_gai_strerror.f)(err)); ++ } ++ return (-1); ++ } ++ return (1); ++ } ++#endif ++ BIOerr(BIO_F_BIO_GETADDRINFO,BIO_R_UNSUPPORTED_METHOD); ++ return (-1); ++ } ++ ++void BIO_freeaddrinfo(struct addrinfo *ai) ++ { ++#ifdef EAI_FAMILY ++ static union { void *p; ++ void (WSAAPI *f)(struct addrinfo *); ++ } p_freeaddrinfo = {NULL}; ++ ++ if ((p_freeaddrinfo.p=DSO_global_lookup("freeaddrinfo"))!=NULL) ++ (*p_freeaddrinfo.f)(ai); ++#endif ++ } + + int BIO_sock_init(void) +- { ++ { + #ifdef OPENSSL_SYS_WINDOWS + static struct WSAData wsa_state; + +@@ -686,8 +737,9 @@ int BIO_get_accept_socket(char *host, in + hint.ai_flags = AI_PASSIVE; + if (h) + { +- if (strchr(h,':')) ++ if ((e = strchr(h,':'))) + { ++ *e = '\0'; + if (h[1]=='\0') h=NULL; + #if OPENSSL_USE_IPV6 + hint.ai_family = AF_INET6; +diff -rup openssl-1.0.1c/crypto/bio/bio.h openssl-1.0.1c-working/crypto/bio/bio.h +--- openssl-1.0.1c/crypto/bio/bio.h 2012-03-06 14:47:26.000000000 +0100 ++++ openssl-1.0.1c-working/crypto/bio/bio.h 2012-06-10 00:06:09.000000000 +0200 +@@ -76,6 +76,9 @@ + # endif + #endif + ++/* under which condition ? */ ++#include <netdb.h> ++ + #ifdef __cplusplus + extern "C" { + #endif +@@ -715,6 +718,14 @@ struct hostent *BIO_gethostbyname(const + * substructures; if the buffer does not suffice, NULL is returned + * and an appropriate error code is set). + */ ++ ++#ifndef EAI_FAMILY ++struct addrinfo { /* dummy interface */ }; ++#endif ++ ++int BIO_getaddrinfo(const char *hostname, const char *servname, ++ const struct addrinfo *hints, struct addrinfo **res); ++void BIO_freeaddrinfo(struct addrinfo *ai); + int BIO_sock_error(int sock); + int BIO_socket_ioctl(int fd, long type, void *arg); + int BIO_socket_nbio(int fd,int mode); +@@ -782,6 +793,7 @@ void ERR_load_BIO_strings(void); + #define BIO_F_BIO_CALLBACK_CTRL 131 + #define BIO_F_BIO_CTRL 103 + #define BIO_F_BIO_GETHOSTBYNAME 120 ++#define BIO_F_BIO_GETADDRINFO 133 + #define BIO_F_BIO_GETS 104 + #define BIO_F_BIO_GET_ACCEPT_SOCKET 105 + #define BIO_F_BIO_GET_HOST_IP 106 +diff -rup openssl-1.0.1c/crypto/bio/bio_err.c openssl-1.0.1c-working/crypto/bio/bio_err.c +--- openssl-1.0.1c/crypto/bio/bio_err.c 2011-12-27 15:37:43.000000000 +0100 ++++ openssl-1.0.1c-working/crypto/bio/bio_err.c 2012-06-10 01:27:30.000000000 +0200 +@@ -76,6 +76,7 @@ static ERR_STRING_DATA BIO_str_functs[]= + {ERR_FUNC(BIO_F_BIO_CALLBACK_CTRL), "BIO_callback_ctrl"}, + {ERR_FUNC(BIO_F_BIO_CTRL), "BIO_ctrl"}, + {ERR_FUNC(BIO_F_BIO_GETHOSTBYNAME), "BIO_gethostbyname"}, ++{ERR_FUNC(BIO_F_BIO_GETADDRINFO), "BIO_getaddrinfo"}, + {ERR_FUNC(BIO_F_BIO_GETS), "BIO_gets"}, + {ERR_FUNC(BIO_F_BIO_GET_ACCEPT_SOCKET), "BIO_get_accept_socket"}, + {ERR_FUNC(BIO_F_BIO_GET_HOST_IP), "BIO_get_host_ip"}, +diff -rup openssl-1.0.1c/crypto/crypto.h openssl-1.0.1c-working/crypto/crypto.h +--- openssl-1.0.1c/crypto/crypto.h 2011-06-01 18:54:03.000000000 +0200 ++++ openssl-1.0.1c-working/crypto/crypto.h 2012-06-10 01:01:26.000000000 +0200 +@@ -222,6 +222,7 @@ typedef struct openssl_item_st + #define CRYPTO_LOCK_FIPS 39 + #define CRYPTO_LOCK_FIPS2 40 + #define CRYPTO_NUM_LOCKS 41 ++#define CRYPTO_LOCK_GAI_STRERROR 42 + + #define CRYPTO_LOCK 1 + #define CRYPTO_UNLOCK 2
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120611175720.73AE0106577C>