changeset 15054:f58283ce58ea

[gaim-migrate @ 17838] Validate the IP address entered by the user in prefs before trying to use it. This should fix a few crashes. I feel like we could get rid of gaim_network_ip_atoi() and just use inet_aton() committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 28 Nov 2006 09:05:34 +0000
parents 06b0b50d3617
children 577ddea3ab82
files gtk/gtkprefs.c libgaim/core.c libgaim/network.c
diffstat 3 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/gtkprefs.c	Tue Nov 28 08:44:12 2006 +0000
+++ b/gtk/gtkprefs.c	Tue Nov 28 09:05:34 2006 +0000
@@ -967,6 +967,11 @@
 
 static void network_ip_changed(GtkEntry *entry, gpointer data)
 {
+	/*
+	 * TODO: It would be nice if we could validate this and show a
+	 *       red background in the box when the IP address is invalid
+	 *       and a green background when the IP address is valid.
+	 */
 	gaim_network_set_public_ip(gtk_entry_get_text(entry));
 }
 
--- a/libgaim/core.c	Tue Nov 28 08:44:12 2006 +0000
+++ b/libgaim/core.c	Tue Nov 28 09:05:34 2006 +0000
@@ -136,7 +136,10 @@
 	gaim_xfers_init();
 	gaim_idle_init();
 
-	/* Call this early on to try to auto-detect our IP address */
+	/*
+	 * Call this early on to try to auto-detect our IP address and
+	 * hopefully save some time later.
+	 */
 	gaim_network_get_my_ip(-1);
 
 	if (ops != NULL && ops->ui_init != NULL)
--- a/libgaim/network.c	Tue Nov 28 08:44:12 2006 +0000
+++ b/libgaim/network.c	Tue Nov 28 09:05:34 2006 +0000
@@ -166,7 +166,8 @@
 	/* Check if the user specified an IP manually */
 	if (!gaim_prefs_get_bool("/core/network/auto_ip")) {
 		ip = gaim_network_get_public_ip();
-		if ((ip != NULL) && (*ip != '\0'))
+		/* Make sure the IP address entered by the user is valid */
+		if ((ip != NULL) && (gaim_network_ip_atoi(ip) != NULL))
 			return ip;
 	}