[gaim-migrate @ 14884]

Mon, 19 Dec 2005 17:16:15 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Mon, 19 Dec 2005 17:16:15 +0000
changeset 12565
8601c9c26f93
parent 12564
2b7ce64d0e05
child 12566
e2374865a90a

[gaim-migrate @ 14884]
Don't assume that gethostbyname() was successful. This should fix #1384291.

src/protocols/simple/simple.c file | annotate | diff | comparison | revisions
--- a/src/protocols/simple/simple.c	Mon Dec 19 17:06:59 2005 +0000
+++ b/src/protocols/simple/simple.c	Mon Dec 19 17:16:15 2005 +0000
@@ -1239,6 +1239,12 @@
 
 	} else { /* UDP */
 		gaim_debug_info("simple", "using udp with server %s and port %d\n", hostname, port);
+
+		/** TODO: this should probably be async, right? */
+		if (!(h = gethostbyname(hostname))) {
+			gaim_connection_error(sip->gc, _("Couldn't resolve host"));
+		}
+
 		sip->fd = socket(AF_INET, SOCK_DGRAM, 0);
 
 		addr.sin_family = AF_INET;
@@ -1254,7 +1260,6 @@
 		sip->serveraddr.sin_family = AF_INET;
 		sip->serveraddr.sin_port = htons(port);
 
-		h = gethostbyname(hostname);
 		sip->serveraddr.sin_addr.s_addr = ((struct in_addr*)h->h_addr)->s_addr;
 		sip->ip = g_strdup(gaim_network_get_my_ip(sip->listenfd));
 		sip->resendtimeout = gaim_timeout_add(2500, (GSourceFunc)resend_timeout, sip);

mercurial