2005-05-05 Mikael Hallendal <micke@imendio.com>
authorhallski <hallski>
Thu, 05 May 2005 19:07:15 +0000
changeset 117 5f6f1f273d6a
parent 116 13c951a33aca
child 118 3bb6f6410dd4
2005-05-05 Mikael Hallendal <micke@imendio.com> * loudmouth/lm-ssl.c: (_lm_ssl_read): - Don't accidently return a negative bytes_read. - Fixes LM-3, reported by Daniel Lavalliere.
ChangeLog
loudmouth/lm-ssl.c
--- a/ChangeLog	Thu May 05 18:58:44 2005 +0000
+++ b/ChangeLog	Thu May 05 19:07:15 2005 +0000
@@ -1,3 +1,9 @@
+2005-05-05  Mikael Hallendal  <micke@imendio.com>
+
+	* loudmouth/lm-ssl.c: (_lm_ssl_read):
+	- Don't accidently return a negative bytes_read.
+	- Fixes LM-3, reported by Daniel Lavalliere.
+
 2005-05-05  Mikael Hallendal  <micke@imendio.com>
 
 	* loudmouth/lm-connection.c: (connection_free):
--- a/loudmouth/lm-ssl.c	Thu May 05 18:58:44 2005 +0000
+++ b/loudmouth/lm-ssl.c	Thu May 05 19:07:15 2005 +0000
@@ -202,8 +202,10 @@
 _lm_ssl_read (LmSSL *ssl, gchar *buf, gint len, gsize *bytes_read)
 {
 	GIOStatus status;
-	
-	*bytes_read = gnutls_record_recv (ssl->gnutls_session, buf, len);
+	gint      b_read;
+
+	*bytes_read = 0;
+	b_read = gnutls_record_recv (ssl->gnutls_session, buf, len);
 
 	//g_print ("%d bytes read\n", size);
 
@@ -211,12 +213,12 @@
 		status = G_IO_STATUS_AGAIN;
 	}
 	else if (*bytes_read > len) {
-		*bytes_read = 0;
 		status = G_IO_STATUS_EOF;
 	}
 	else if (*bytes_read < 0) {
 		status = G_IO_STATUS_ERROR;
 	} else {
+		*bytes_read = (guint) b_read;
 		status = G_IO_STATUS_NORMAL;
 	}