aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssl_openssl.c
diff options
context:
space:
mode:
authorulim <a.sporto+bee@gmail.com>2008-04-14 15:10:53 +0200
committerulim <a.sporto+bee@gmail.com>2008-04-14 15:10:53 +0200
commitb79308b943149d729b1daea8c56cff9fc02711a0 (patch)
treea5f80445ed63d864703941474dc6cf8998df3136 /lib/ssl_openssl.c
parent6cac643f6933e431b90fcb937dec505f989e6a53 (diff)
parentaa311173a85020bcbbbf61135a5451e171d422f5 (diff)
merged in upstream r379 (somewhere after 1.2-3).
Just one trivial conflict in the jabber Makefile, went smoothly.
Diffstat (limited to 'lib/ssl_openssl.c')
-rw-r--r--lib/ssl_openssl.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/ssl_openssl.c b/lib/ssl_openssl.c
index b1ba1db9..fc6d433e 100644
--- a/lib/ssl_openssl.c
+++ b/lib/ssl_openssl.c
@@ -61,16 +61,16 @@ void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data
struct scd *conn = g_new0( struct scd, 1 );
conn->fd = proxy_connect( host, port, ssl_connected, conn );
- conn->func = func;
- conn->data = data;
- conn->inpa = -1;
-
if( conn->fd < 0 )
{
g_free( conn );
return NULL;
}
+ conn->func = func;
+ conn->data = data;
+ conn->inpa = -1;
+
return conn;
}
@@ -230,6 +230,21 @@ int ssl_write( void *conn, const char *buf, int len )
return st;
}
+/* Only OpenSSL *really* needs this (and well, maybe NSS). See for more info:
+ http://www.gnu.org/software/gnutls/manual/gnutls.html#index-gnutls_005frecord_005fcheck_005fpending-209
+ http://www.openssl.org/docs/ssl/SSL_pending.html
+
+ Required because OpenSSL empties the TCP buffer completely but doesn't
+ necessarily give us all the unencrypted data.
+
+ Returns 0 if there's nothing left or if we don't have to care (GnuTLS),
+ 1 if there's more data. */
+int ssl_pending( void *conn )
+{
+ return ( ((struct scd*)conn) && ((struct scd*)conn)->established ) ?
+ SSL_pending( ((struct scd*)conn)->ssl ) > 0 : 0;
+}
+
void ssl_disconnect( void *conn_ )
{
struct scd *conn = conn_;