[PATCH] safer open ssl stream_close()
- From: "martin bonnin" <martinbonnin gmail com>
- To: tinymail-devel-list gnome org
- Subject: [PATCH] safer open ssl stream_close()
- Date: Wed, 27 Aug 2008 20:52:59 +0200
Hello,
This removes the "Warning: invalid file descriptor -1 in syscall close()" seen when using valgrind with tinymail.
stream_close() is called twice in a row on the same stream.
There might be more implications than just this valgrind warning, full details here
http://www.tinymail.org/trac/tinymail/ticket/62#preview
--
Martin
--- a/libtinymail-camel/camel-lite/camel/camel-tcp-stream-openssl.c 2008-08-27 20:28:49.000000000 +0200
+++ b/libtinymail-camel/camel-lite/camel/camel-tcp-stream-openssl.c 2008-08-27 20:32:44.000000000 +0200
@@ -691,13 +691,18 @@
static int
stream_close (CamelStream *stream)
{
- close_ssl_connection (((CamelTcpStreamSSL *)stream)->priv->ssl);
- ((CamelTcpStreamSSL *)stream)->priv->ssl = NULL;
+ if( ((CamelTcpStreamSSL *)stream)->priv->ssl ){
+ close_ssl_connection (((CamelTcpStreamSSL *)stream)->priv->ssl);
+ ((CamelTcpStreamSSL *)stream)->priv->ssl = NULL;
+ }
- if (close (((CamelTcpStreamSSL *)stream)->priv->sockfd) == -1)
- return -1;
+ if( ((CamelTcpStreamSSL *)stream)->priv->sockfd != -1 ){
+ if (close (((CamelTcpStreamSSL *)stream)->priv->sockfd) == -1)
+ return -1;
+
+ ((CamelTcpStreamSSL *)stream)->priv->sockfd = -1;
+ }
- ((CamelTcpStreamSSL *)stream)->priv->sockfd = -1;
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]