2005-01-19 Mikael Hallendal <micke@imendio.com>
authorhallski <hallski>
Wed, 19 Jan 2005 22:12:15 +0000
changeset 105 9eafd0e8c702
parent 104 f43fde0f89d4
child 106 449f5a0dcdde
2005-01-19 Mikael Hallendal <micke@imendio.com> * loudmouth/lm-connection.c: (connection_in_event): * loudmouth/lm-ssl.c: (_lm_ssl_read): - Seems GnuTLS returns a huge size as read bytes when the server is disconnected. Check if returned read size is larger than asked for if so, set the connection to be hung up. - Fixes bug #164592
ChangeLog
loudmouth/lm-connection.c
loudmouth/lm-ssl.c
--- a/ChangeLog	Mon Nov 08 13:21:52 2004 +0000
+++ b/ChangeLog	Wed Jan 19 22:12:15 2005 +0000
@@ -1,3 +1,12 @@
+2005-01-19  Mikael Hallendal  <micke@imendio.com>
+
+	* loudmouth/lm-connection.c: (connection_in_event):
+	* loudmouth/lm-ssl.c: (_lm_ssl_read):
+	- Seems GnuTLS returns a huge size as read bytes when the server is
+	  disconnected. Check if returned read size is larger than asked for
+	  if so, set the connection to be hung up.
+	- Fixes bug #164592
+
 2004-11-08  Mikael Hallendal  <micke@imendio.com>
 
 	* examples/lm-change-password.c: Added SSL support
@@ -6,7 +15,7 @@
 2004-10-31  Mikael Hallendal  <micke@imendio.com>
 
 	* Release 0.17.2
-        
+
 	* NEWS: Updated for 0.17.2
 	* configure.in: Bumped version to 0.17.2
 
--- a/loudmouth/lm-connection.c	Mon Nov 08 13:21:52 2004 +0000
+++ b/loudmouth/lm-connection.c	Wed Jan 19 22:12:15 2005 +0000
@@ -691,7 +691,7 @@
 		     LmConnection *connection)
 {
 	gchar     buf[IN_BUFFER_SIZE];
-	gsize      bytes_read;
+	gsize     bytes_read;
 	GIOStatus status;
        
 	if (!connection->io_channel) {
@@ -708,7 +708,7 @@
 						  NULL);
 	}
 
-	if (status != G_IO_STATUS_NORMAL) {
+	if (status != G_IO_STATUS_NORMAL || bytes_read < 0) {
 		gint reason;
 		
 		switch (status) {
--- a/loudmouth/lm-ssl.c	Mon Nov 08 13:21:52 2004 +0000
+++ b/loudmouth/lm-ssl.c	Wed Jan 19 22:12:15 2005 +0000
@@ -206,11 +206,17 @@
 	GIOStatus status;
 	
 	*bytes_read = gnutls_record_recv (ssl->gnutls_session, buf, len);
-	
+
+	//g_print ("%d bytes read\n", size);
+
 	if (*bytes_read == GNUTLS_E_AGAIN) {
 		status = G_IO_STATUS_AGAIN;
 	}
-	else if (*bytes_read <= 0) {
+	else if (*bytes_read > len) {
+		*bytes_read = 0;
+		status = G_IO_STATUS_EOF;
+	}
+	else if (*bytes_read < 0) {
 		status = G_IO_STATUS_ERROR;
 	} else {
 		status = G_IO_STATUS_NORMAL;