[evolution-data-server] Sanitize empty-string proxy hostnames at the API entry point



commit d6d1a38a2deb7d33d80c10e115e9c31229104ba5
Author: Federico Mena Quintero <federico novell com>
Date:   Tue Jun 1 14:15:26 2010 -0500

    Sanitize empty-string proxy hostnames at the API entry point
    
    This way the rest of the code can assume that (proxy_host == NULL) means
    that no proxy is set; it doesn't need to check for empty strings.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 camel/camel-session.c    |    9 +++++++--
 camel/camel-tcp-stream.c |   10 ++++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/camel/camel-session.c b/camel/camel-session.c
index d76ce31..40c3c21 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -1121,8 +1121,13 @@ camel_session_set_socks_proxy (CamelSession *session, const gchar *socks_host, i
 	if (session->priv->socks_proxy_host)
 		g_free (session->priv->socks_proxy_host);
 
-	session->priv->socks_proxy_host = g_strdup (socks_host);
-	session->priv->socks_proxy_port = socks_port;
+	if (socks_host && socks_host[0] != '\0') {
+		session->priv->socks_proxy_host = g_strdup (socks_host);
+		session->priv->socks_proxy_port = socks_port;
+	} else {
+		session->priv->socks_proxy_host = NULL;
+		session->priv->socks_proxy_port = 0;
+	}
 }
 
 /**
diff --git a/camel/camel-tcp-stream.c b/camel/camel-tcp-stream.c
index 9c37e99..c66cc8b 100644
--- a/camel/camel-tcp-stream.c
+++ b/camel/camel-tcp-stream.c
@@ -223,8 +223,14 @@ camel_tcp_stream_set_socks_proxy (CamelTcpStream *stream, const gchar *socks_hos
 	priv = stream->priv;
 
 	g_free (priv->socks_host);
-	priv->socks_host = g_strdup (socks_host);
-	priv->socks_port = socks_port;
+
+	if (socks_host && socks_host[0] != '\0') {
+		priv->socks_host = g_strdup (socks_host);
+		priv->socks_port = socks_port;
+	} else {
+		priv->socks_host = NULL;
+		priv->socks_port = 0;
+	}
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]