mirror of
https://github.com/curl/curl.git
synced 2025-09-28 06:56:50 +03:00
gnutls: only translate winsock errors for old versions
Bugfix: https handshake fails using gnutls 3 on windows
http://sourceforge.net/tracker/index.php?func=detail&aid=3441084&group_id=976&atid=100976
New gnutls versions have an error handler that knows about Winsock
errors, which is why gnutls_transport_set_global_errno() was deprecated
and then removed.
This is a correction of commit f5bb370
(blame me) which meant to
reimplement gnutls_transport_set_global_errno(), which is not necessary.
This commit is contained in:
parent
7248439fec
commit
28bac99674
15
lib/gtls.c
15
lib/gtls.c
|
@ -80,15 +80,17 @@ static void tls_log_func(int level, const char *str)
|
||||||
#endif
|
#endif
|
||||||
static bool gtls_inited = FALSE;
|
static bool gtls_inited = FALSE;
|
||||||
|
|
||||||
|
#undef MAP_WINSOCK_ERRORS
|
||||||
#if defined(GNUTLS_VERSION_NUMBER)
|
#if defined(GNUTLS_VERSION_NUMBER)
|
||||||
# if (GNUTLS_VERSION_NUMBER >= 0x020c00)
|
# if (GNUTLS_VERSION_NUMBER >= 0x020c00)
|
||||||
# undef gnutls_transport_set_lowat
|
# undef gnutls_transport_set_lowat
|
||||||
# define gnutls_transport_set_lowat(A,B) Curl_nop_stmt
|
# define gnutls_transport_set_lowat(A,B) Curl_nop_stmt
|
||||||
# define USE_GNUTLS_PRIORITY_SET_DIRECT 1
|
# define USE_GNUTLS_PRIORITY_SET_DIRECT 1
|
||||||
# endif
|
# endif
|
||||||
# if (GNUTLS_VERSION_NUMBER >= 0x020c03)
|
# if (GNUTLS_VERSION_NUMBER < 0x020c03)
|
||||||
# undef gnutls_transport_set_global_errno
|
# ifdef USE_WINSOCK
|
||||||
# define gnutls_transport_set_global_errno(A) SET_ERRNO((A))
|
# define MAP_WINSOCK_ERRORS
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -100,6 +102,7 @@ static bool gtls_inited = FALSE;
|
||||||
* us to get specific about the fourth "flags" argument, and to use arbitrary
|
* us to get specific about the fourth "flags" argument, and to use arbitrary
|
||||||
* private data with gnutls_transport_set_ptr if we wish.
|
* private data with gnutls_transport_set_ptr if we wish.
|
||||||
*
|
*
|
||||||
|
* For old gnutls versions, curl must translate Winsock errors:
|
||||||
* When these custom push and pull callbacks fail, GNU TLS checks its own
|
* When these custom push and pull callbacks fail, GNU TLS checks its own
|
||||||
* session-specific error variable, and when not set also its own global
|
* session-specific error variable, and when not set also its own global
|
||||||
* errno variable, in order to take appropriate action. GNU TLS does not
|
* errno variable, in order to take appropriate action. GNU TLS does not
|
||||||
|
@ -111,7 +114,7 @@ static bool gtls_inited = FALSE;
|
||||||
* error translation must take place in these callbacks.
|
* error translation must take place in these callbacks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
#ifdef MAP_WINSOCK_ERRORS
|
||||||
# define gtls_EINTR 4
|
# define gtls_EINTR 4
|
||||||
# define gtls_EIO 5
|
# define gtls_EIO 5
|
||||||
# define gtls_EAGAIN 11
|
# define gtls_EAGAIN 11
|
||||||
|
@ -132,7 +135,7 @@ static int gtls_mapped_sockerrno(void)
|
||||||
static ssize_t Curl_gtls_push(void *s, const void *buf, size_t len)
|
static ssize_t Curl_gtls_push(void *s, const void *buf, size_t len)
|
||||||
{
|
{
|
||||||
ssize_t ret = swrite(GNUTLS_POINTER_TO_INT_CAST(s), buf, len);
|
ssize_t ret = swrite(GNUTLS_POINTER_TO_INT_CAST(s), buf, len);
|
||||||
#ifdef USE_WINSOCK
|
#ifdef MAP_WINSOCK_ERRORS
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
gnutls_transport_set_global_errno(gtls_mapped_sockerrno());
|
gnutls_transport_set_global_errno(gtls_mapped_sockerrno());
|
||||||
#endif
|
#endif
|
||||||
|
@ -142,7 +145,7 @@ static ssize_t Curl_gtls_push(void *s, const void *buf, size_t len)
|
||||||
static ssize_t Curl_gtls_pull(void *s, void *buf, size_t len)
|
static ssize_t Curl_gtls_pull(void *s, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
ssize_t ret = sread(GNUTLS_POINTER_TO_INT_CAST(s), buf, len);
|
ssize_t ret = sread(GNUTLS_POINTER_TO_INT_CAST(s), buf, len);
|
||||||
#ifdef USE_WINSOCK
|
#ifdef MAP_WINSOCK_ERRORS
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
gnutls_transport_set_global_errno(gtls_mapped_sockerrno());
|
gnutls_transport_set_global_errno(gtls_mapped_sockerrno());
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user