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



commit 9847224a11e765d9c3d5e2494170c4af10e82e0d
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 d83445f..36a2d38 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -167,8 +167,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;
+	}
 }
 
 void
diff --git a/camel/camel-tcp-stream.c b/camel/camel-tcp-stream.c
index aa4fdc7..03707e8 100644
--- a/camel/camel-tcp-stream.c
+++ b/camel/camel-tcp-stream.c
@@ -199,8 +199,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;
+	}
 }
 
 void



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