connect() wrongness in camel's openssl code.
- From: Murray Cumming <murrayc murrayc com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: connect() wrongness in camel's openssl code.
- Date: Mon, 21 May 2007 14:20:21 +0200
This patch allows connect() to actually succeed when using openssl. I
must assume that camel's openssl code (instead of Mozilla NSS) has never
really been tested.
It's the same in the original camel in evolution-data-server, so I'll
submit this patch upstream if you agree.
--
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com
Index: libtinymail-camel/camel-lite/camel/camel-tcp-stream-openssl.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-tcp-stream-openssl.c (revision 2023)
+++ libtinymail-camel/camel-lite/camel/camel-tcp-stream-openssl.c (working copy)
@@ -522,7 +522,6 @@
{
struct sockaddr *saddr = host->ai_addr;
struct timeval tv;
- socklen_t len;
int cancel_fd;
int ret, fd;
@@ -536,7 +535,7 @@
cancel_fd = camel_operation_cancel_fd (NULL);
if (cancel_fd == -1) {
- ret = connect (fd, saddr, len);
+ ret = connect (fd, saddr, sizeof (struct sockaddr));
if (ret == -1) {
close (fd);
return -1;
@@ -550,7 +549,7 @@
flags = fcntl (fd, F_GETFL);
fcntl (fd, F_SETFL, flags | O_NONBLOCK);
- ret = connect (fd, saddr, len);
+ ret = connect (fd, saddr, sizeof (struct sockaddr));
if (ret == 0) {
fcntl (fd, F_SETFL, flags);
return fd;
@@ -580,7 +579,7 @@
errno = EINTR;
return -1;
} else {
- len = sizeof (int);
+ socklen_t len = sizeof (int);
if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &len) == -1) {
close (fd);
Index: libtinymail-camel/camel-lite/ChangeLog
===================================================================
--- libtinymail-camel/camel-lite/ChangeLog (revision 2023)
+++ libtinymail-camel/camel-lite/ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2007-05-21 Murray Cumming <murrayc murrayc com>
+
+ * camel/camel-tcp-stream-openssl.c: (socket_connect): When calling
+ the standard connect () function, use sizeof (struct sockaddr) instead of
+ just passing an uninitialized socklen_t, so that this can actually succeed,
+ instead of failing with an Invalid Argument errno.
+
2007-05-16 Murray Cumming <murrayc murrayc com>
* camel/camel-mime-message.c: (camel_mime_message_set_subject):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]