Loading CHANGES +2 −0 Changes for CHANGES: 2 added lines, 0 removed lines. Original line number Original line Diff line number Diff line Loading @@ -9,6 +9,8 @@ Kamil Dudka (4 Apr 2010) Kamil Dudka (4 Apr 2010) - Eliminated a race condition in Curl_resolv_timeout(). - Eliminated a race condition in Curl_resolv_timeout(). - Refactorized interface of Curl_ssl_recv()/Curl_ssl_send(). Daniel Stenberg (1 Apr 2010) Daniel Stenberg (1 Apr 2010) - Matt Wixson found and fixed a bug in the SCP/SFTP area where the code - Matt Wixson found and fixed a bug in the SCP/SFTP area where the code treated a 0 return code from libssh2 to be the same as EAGAIN while in treated a 0 return code from libssh2 to be the same as EAGAIN while in Loading lib/gtls.c +17 −16 Changes for lib/gtls.c: 17 added lines, 16 removed lines. Original line number Original line Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____| * * * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * * * This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms Loading Loading @@ -638,18 +638,21 @@ Curl_gtls_connect(struct connectdata *conn, } } /* return number of sent (non-SSL) bytes */ /* for documentation see Curl_ssl_send() in sslgen.h */ ssize_t Curl_gtls_send(struct connectdata *conn, ssize_t Curl_gtls_send(struct connectdata *conn, int sockindex, int sockindex, const void *mem, const void *mem, size_t len) size_t len, int *curlcode) { { ssize_t rc = gnutls_record_send(conn->ssl[sockindex].session, mem, len); ssize_t rc = gnutls_record_send(conn->ssl[sockindex].session, mem, len); if(rc < 0 ) { if(rc < 0 ) { if(rc == GNUTLS_E_AGAIN) *curlcode = (rc == GNUTLS_E_AGAIN) return 0; /* EWOULDBLOCK equivalent */ ? /* EWOULDBLOCK */ -1 rc = -1; /* generic error code for send failure */ : CURLE_SEND_ERROR; rc = -1; } } return rc; return rc; Loading Loading @@ -748,22 +751,18 @@ int Curl_gtls_shutdown(struct connectdata *conn, int sockindex) return retval; return retval; } } /* /* for documentation see Curl_ssl_recv() in sslgen.h */ * If the read would block we return -1 and set 'wouldblock' to TRUE. * Otherwise we return the amount of data read. Other errors should return -1 * and set 'wouldblock' to FALSE. */ ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */ ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */ int num, /* socketindex */ int num, /* socketindex */ char *buf, /* store read data here */ char *buf, /* store read data here */ size_t buffersize, /* max amount to read */ size_t buffersize, /* max amount to read */ bool *wouldblock) int *curlcode) { { ssize_t ret; ssize_t ret; ret = gnutls_record_recv(conn->ssl[num].session, buf, buffersize); ret = gnutls_record_recv(conn->ssl[num].session, buf, buffersize); if((ret == GNUTLS_E_AGAIN) || (ret == GNUTLS_E_INTERRUPTED)) { if((ret == GNUTLS_E_AGAIN) || (ret == GNUTLS_E_INTERRUPTED)) { *wouldblock = TRUE; *curlcode = -1; return -1; return -1; } } Loading @@ -773,20 +772,22 @@ ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */ CURLcode rc = handshake(conn, conn->ssl[num].session, num, FALSE); CURLcode rc = handshake(conn, conn->ssl[num].session, num, FALSE); if(rc) if(rc) /* handshake() writes error message on its own */ /* handshake() writes error message on its own */ return rc; *curlcode = rc; *wouldblock = TRUE; /* then return as if this was a wouldblock */ else *curlcode = -1; /* then return as if this was a wouldblock */ return -1; return -1; } } *wouldblock = FALSE; if(!ret) { if(!ret) { failf(conn->data, "Peer closed the TLS connection"); failf(conn->data, "Peer closed the TLS connection"); *curlcode = CURLE_RECV_ERROR; return -1; return -1; } } if(ret < 0) { if(ret < 0) { failf(conn->data, "GnuTLS recv error (%d): %s", failf(conn->data, "GnuTLS recv error (%d): %s", (int)ret, gnutls_strerror((int)ret)); (int)ret, gnutls_strerror((int)ret)); *curlcode = CURLE_RECV_ERROR; return -1; return -1; } } Loading lib/gtls.h +8 −8 Changes for lib/gtls.h: 8 added lines, 8 removed lines. Original line number Original line Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____| * * * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * * * This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms Loading Loading @@ -35,14 +35,14 @@ void Curl_gtls_close_all(struct SessionHandle *data); /* close a SSL connection */ /* close a SSL connection */ void Curl_gtls_close(struct connectdata *conn, int sockindex); void Curl_gtls_close(struct connectdata *conn, int sockindex); /* return number of sent (non-SSL) bytes */ /* for documentation see Curl_ssl_send() in sslgen.h */ ssize_t Curl_gtls_send(struct connectdata *conn, int sockindex, ssize_t Curl_gtls_send(struct connectdata *conn, int sockindex, const void *mem, size_t len); const void *mem, size_t len, int *curlcode); ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */ int num, /* socketindex */ /* for documentation see Curl_ssl_recv() in sslgen.h */ char *buf, /* store read data here */ ssize_t Curl_gtls_recv(struct connectdata *conn, int num, char *buf, size_t buffersize, /* max amount to read */ size_t buffersize, int *curlcode); bool *wouldblock); void Curl_gtls_session_free(void *ptr); void Curl_gtls_session_free(void *ptr); size_t Curl_gtls_version(char *buffer, size_t size); size_t Curl_gtls_version(char *buffer, size_t size); int Curl_gtls_shutdown(struct connectdata *conn, int sockindex); int Curl_gtls_shutdown(struct connectdata *conn, int sockindex); Loading lib/nss.c +17 −14 Changes for lib/nss.c: 17 added lines, 14 removed lines. Original line number Original line Diff line number Diff line Loading @@ -1340,47 +1340,50 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex) return curlerr; return curlerr; } } /* return number of sent (non-SSL) bytes */ /* for documentation see Curl_ssl_send() in sslgen.h */ int Curl_nss_send(struct connectdata *conn, /* connection data */ int Curl_nss_send(struct connectdata *conn, /* connection data */ int sockindex, /* socketindex */ int sockindex, /* socketindex */ const void *mem, /* send this data */ const void *mem, /* send this data */ size_t len) /* amount to write */ size_t len, /* amount to write */ int *curlcode) { { int rc; int rc; rc = PR_Send(conn->ssl[sockindex].handle, mem, (int)len, 0, -1); rc = PR_Send(conn->ssl[sockindex].handle, mem, (int)len, 0, -1); if(rc < 0) { if(rc < 0) { failf(conn->data, "SSL write: error %d", PR_GetError()); PRInt32 err = PR_GetError(); if(err == PR_WOULD_BLOCK_ERROR) *curlcode = -1; /* EWOULDBLOCK */ else { failf(conn->data, "SSL write: error %d", err); *curlcode = CURLE_SEND_ERROR; } return -1; return -1; } } return rc; /* number of bytes */ return rc; /* number of bytes */ } } /* /* for documentation see Curl_ssl_recv() in sslgen.h */ * If the read would block we return -1 and set 'wouldblock' to TRUE. * Otherwise we return the amount of data read. Other errors should return -1 * and set 'wouldblock' to FALSE. */ ssize_t Curl_nss_recv(struct connectdata * conn, /* connection data */ ssize_t Curl_nss_recv(struct connectdata * conn, /* connection data */ int num, /* socketindex */ int num, /* socketindex */ char *buf, /* store read data here */ char *buf, /* store read data here */ size_t buffersize, /* max amount to read */ size_t buffersize, /* max amount to read */ bool * wouldblock) int *curlcode) { { ssize_t nread; ssize_t nread; nread = PR_Recv(conn->ssl[num].handle, buf, (int)buffersize, 0, -1); nread = PR_Recv(conn->ssl[num].handle, buf, (int)buffersize, 0, -1); *wouldblock = FALSE; if(nread < 0) { if(nread < 0) { /* failed SSL read */ /* failed SSL read */ PRInt32 err = PR_GetError(); PRInt32 err = PR_GetError(); if(err == PR_WOULD_BLOCK_ERROR) { if(err == PR_WOULD_BLOCK_ERROR) *wouldblock = TRUE; *curlcode = -1; /* EWOULDBLOCK */ return -1; /* basically EWOULDBLOCK */ else { } failf(conn->data, "SSL read: errno %d", err); failf(conn->data, "SSL read: errno %d", err); *curlcode = CURLE_RECV_ERROR; } return -1; return -1; } } return nread; return nread; Loading lib/nssg.h +7 −3 Changes for lib/nssg.h: 7 added lines, 3 removed lines. Original line number Original line Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____| * * * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * * * This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms Loading Loading @@ -42,15 +42,19 @@ int Curl_nss_close_all(struct SessionHandle *data); int Curl_nss_init(void); int Curl_nss_init(void); void Curl_nss_cleanup(void); void Curl_nss_cleanup(void); /* for documentation see Curl_ssl_send() in sslgen.h */ int Curl_nss_send(struct connectdata *conn, int Curl_nss_send(struct connectdata *conn, int sockindex, int sockindex, const void *mem, const void *mem, size_t len); size_t len, int *curlcode); /* for documentation see Curl_ssl_recv() in sslgen.h */ ssize_t Curl_nss_recv(struct connectdata *conn, /* connection data */ ssize_t Curl_nss_recv(struct connectdata *conn, /* connection data */ int num, /* socketindex */ int num, /* socketindex */ char *buf, /* store read data here */ char *buf, /* store read data here */ size_t buffersize, /* max amount to read */ size_t buffersize, /* max amount to read */ bool *wouldblock); int *curlcode); size_t Curl_nss_version(char *buffer, size_t size); size_t Curl_nss_version(char *buffer, size_t size); int Curl_nss_check_cxn(struct connectdata *cxn); int Curl_nss_check_cxn(struct connectdata *cxn); Loading Loading
CHANGES +2 −0 Changes for CHANGES: 2 added lines, 0 removed lines. Original line number Original line Diff line number Diff line Loading @@ -9,6 +9,8 @@ Kamil Dudka (4 Apr 2010) Kamil Dudka (4 Apr 2010) - Eliminated a race condition in Curl_resolv_timeout(). - Eliminated a race condition in Curl_resolv_timeout(). - Refactorized interface of Curl_ssl_recv()/Curl_ssl_send(). Daniel Stenberg (1 Apr 2010) Daniel Stenberg (1 Apr 2010) - Matt Wixson found and fixed a bug in the SCP/SFTP area where the code - Matt Wixson found and fixed a bug in the SCP/SFTP area where the code treated a 0 return code from libssh2 to be the same as EAGAIN while in treated a 0 return code from libssh2 to be the same as EAGAIN while in Loading
lib/gtls.c +17 −16 Changes for lib/gtls.c: 17 added lines, 16 removed lines. Original line number Original line Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____| * * * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * * * This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms Loading Loading @@ -638,18 +638,21 @@ Curl_gtls_connect(struct connectdata *conn, } } /* return number of sent (non-SSL) bytes */ /* for documentation see Curl_ssl_send() in sslgen.h */ ssize_t Curl_gtls_send(struct connectdata *conn, ssize_t Curl_gtls_send(struct connectdata *conn, int sockindex, int sockindex, const void *mem, const void *mem, size_t len) size_t len, int *curlcode) { { ssize_t rc = gnutls_record_send(conn->ssl[sockindex].session, mem, len); ssize_t rc = gnutls_record_send(conn->ssl[sockindex].session, mem, len); if(rc < 0 ) { if(rc < 0 ) { if(rc == GNUTLS_E_AGAIN) *curlcode = (rc == GNUTLS_E_AGAIN) return 0; /* EWOULDBLOCK equivalent */ ? /* EWOULDBLOCK */ -1 rc = -1; /* generic error code for send failure */ : CURLE_SEND_ERROR; rc = -1; } } return rc; return rc; Loading Loading @@ -748,22 +751,18 @@ int Curl_gtls_shutdown(struct connectdata *conn, int sockindex) return retval; return retval; } } /* /* for documentation see Curl_ssl_recv() in sslgen.h */ * If the read would block we return -1 and set 'wouldblock' to TRUE. * Otherwise we return the amount of data read. Other errors should return -1 * and set 'wouldblock' to FALSE. */ ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */ ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */ int num, /* socketindex */ int num, /* socketindex */ char *buf, /* store read data here */ char *buf, /* store read data here */ size_t buffersize, /* max amount to read */ size_t buffersize, /* max amount to read */ bool *wouldblock) int *curlcode) { { ssize_t ret; ssize_t ret; ret = gnutls_record_recv(conn->ssl[num].session, buf, buffersize); ret = gnutls_record_recv(conn->ssl[num].session, buf, buffersize); if((ret == GNUTLS_E_AGAIN) || (ret == GNUTLS_E_INTERRUPTED)) { if((ret == GNUTLS_E_AGAIN) || (ret == GNUTLS_E_INTERRUPTED)) { *wouldblock = TRUE; *curlcode = -1; return -1; return -1; } } Loading @@ -773,20 +772,22 @@ ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */ CURLcode rc = handshake(conn, conn->ssl[num].session, num, FALSE); CURLcode rc = handshake(conn, conn->ssl[num].session, num, FALSE); if(rc) if(rc) /* handshake() writes error message on its own */ /* handshake() writes error message on its own */ return rc; *curlcode = rc; *wouldblock = TRUE; /* then return as if this was a wouldblock */ else *curlcode = -1; /* then return as if this was a wouldblock */ return -1; return -1; } } *wouldblock = FALSE; if(!ret) { if(!ret) { failf(conn->data, "Peer closed the TLS connection"); failf(conn->data, "Peer closed the TLS connection"); *curlcode = CURLE_RECV_ERROR; return -1; return -1; } } if(ret < 0) { if(ret < 0) { failf(conn->data, "GnuTLS recv error (%d): %s", failf(conn->data, "GnuTLS recv error (%d): %s", (int)ret, gnutls_strerror((int)ret)); (int)ret, gnutls_strerror((int)ret)); *curlcode = CURLE_RECV_ERROR; return -1; return -1; } } Loading
lib/gtls.h +8 −8 Changes for lib/gtls.h: 8 added lines, 8 removed lines. Original line number Original line Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____| * * * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * * * This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms Loading Loading @@ -35,14 +35,14 @@ void Curl_gtls_close_all(struct SessionHandle *data); /* close a SSL connection */ /* close a SSL connection */ void Curl_gtls_close(struct connectdata *conn, int sockindex); void Curl_gtls_close(struct connectdata *conn, int sockindex); /* return number of sent (non-SSL) bytes */ /* for documentation see Curl_ssl_send() in sslgen.h */ ssize_t Curl_gtls_send(struct connectdata *conn, int sockindex, ssize_t Curl_gtls_send(struct connectdata *conn, int sockindex, const void *mem, size_t len); const void *mem, size_t len, int *curlcode); ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */ int num, /* socketindex */ /* for documentation see Curl_ssl_recv() in sslgen.h */ char *buf, /* store read data here */ ssize_t Curl_gtls_recv(struct connectdata *conn, int num, char *buf, size_t buffersize, /* max amount to read */ size_t buffersize, int *curlcode); bool *wouldblock); void Curl_gtls_session_free(void *ptr); void Curl_gtls_session_free(void *ptr); size_t Curl_gtls_version(char *buffer, size_t size); size_t Curl_gtls_version(char *buffer, size_t size); int Curl_gtls_shutdown(struct connectdata *conn, int sockindex); int Curl_gtls_shutdown(struct connectdata *conn, int sockindex); Loading
lib/nss.c +17 −14 Changes for lib/nss.c: 17 added lines, 14 removed lines. Original line number Original line Diff line number Diff line Loading @@ -1340,47 +1340,50 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex) return curlerr; return curlerr; } } /* return number of sent (non-SSL) bytes */ /* for documentation see Curl_ssl_send() in sslgen.h */ int Curl_nss_send(struct connectdata *conn, /* connection data */ int Curl_nss_send(struct connectdata *conn, /* connection data */ int sockindex, /* socketindex */ int sockindex, /* socketindex */ const void *mem, /* send this data */ const void *mem, /* send this data */ size_t len) /* amount to write */ size_t len, /* amount to write */ int *curlcode) { { int rc; int rc; rc = PR_Send(conn->ssl[sockindex].handle, mem, (int)len, 0, -1); rc = PR_Send(conn->ssl[sockindex].handle, mem, (int)len, 0, -1); if(rc < 0) { if(rc < 0) { failf(conn->data, "SSL write: error %d", PR_GetError()); PRInt32 err = PR_GetError(); if(err == PR_WOULD_BLOCK_ERROR) *curlcode = -1; /* EWOULDBLOCK */ else { failf(conn->data, "SSL write: error %d", err); *curlcode = CURLE_SEND_ERROR; } return -1; return -1; } } return rc; /* number of bytes */ return rc; /* number of bytes */ } } /* /* for documentation see Curl_ssl_recv() in sslgen.h */ * If the read would block we return -1 and set 'wouldblock' to TRUE. * Otherwise we return the amount of data read. Other errors should return -1 * and set 'wouldblock' to FALSE. */ ssize_t Curl_nss_recv(struct connectdata * conn, /* connection data */ ssize_t Curl_nss_recv(struct connectdata * conn, /* connection data */ int num, /* socketindex */ int num, /* socketindex */ char *buf, /* store read data here */ char *buf, /* store read data here */ size_t buffersize, /* max amount to read */ size_t buffersize, /* max amount to read */ bool * wouldblock) int *curlcode) { { ssize_t nread; ssize_t nread; nread = PR_Recv(conn->ssl[num].handle, buf, (int)buffersize, 0, -1); nread = PR_Recv(conn->ssl[num].handle, buf, (int)buffersize, 0, -1); *wouldblock = FALSE; if(nread < 0) { if(nread < 0) { /* failed SSL read */ /* failed SSL read */ PRInt32 err = PR_GetError(); PRInt32 err = PR_GetError(); if(err == PR_WOULD_BLOCK_ERROR) { if(err == PR_WOULD_BLOCK_ERROR) *wouldblock = TRUE; *curlcode = -1; /* EWOULDBLOCK */ return -1; /* basically EWOULDBLOCK */ else { } failf(conn->data, "SSL read: errno %d", err); failf(conn->data, "SSL read: errno %d", err); *curlcode = CURLE_RECV_ERROR; } return -1; return -1; } } return nread; return nread; Loading
lib/nssg.h +7 −3 Changes for lib/nssg.h: 7 added lines, 3 removed lines. Original line number Original line Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____| * * * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * * * This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms Loading Loading @@ -42,15 +42,19 @@ int Curl_nss_close_all(struct SessionHandle *data); int Curl_nss_init(void); int Curl_nss_init(void); void Curl_nss_cleanup(void); void Curl_nss_cleanup(void); /* for documentation see Curl_ssl_send() in sslgen.h */ int Curl_nss_send(struct connectdata *conn, int Curl_nss_send(struct connectdata *conn, int sockindex, int sockindex, const void *mem, const void *mem, size_t len); size_t len, int *curlcode); /* for documentation see Curl_ssl_recv() in sslgen.h */ ssize_t Curl_nss_recv(struct connectdata *conn, /* connection data */ ssize_t Curl_nss_recv(struct connectdata *conn, /* connection data */ int num, /* socketindex */ int num, /* socketindex */ char *buf, /* store read data here */ char *buf, /* store read data here */ size_t buffersize, /* max amount to read */ size_t buffersize, /* max amount to read */ bool *wouldblock); int *curlcode); size_t Curl_nss_version(char *buffer, size_t size); size_t Curl_nss_version(char *buffer, size_t size); int Curl_nss_check_cxn(struct connectdata *cxn); int Curl_nss_check_cxn(struct connectdata *cxn); Loading