changeset 21463:2b6553584385

Don't allow the buffer to be overrun when you have lots of local IPs.
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 12 Nov 2007 23:16:52 +0000
parents 31fc6a0769ce
children 577d90f8794e
files libpurple/protocols/bonjour/jabber.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/jabber.c	Mon Nov 12 23:10:08 2007 +0000
+++ b/libpurple/protocols/bonjour/jabber.c	Mon Nov 12 23:16:52 2007 +0000
@@ -997,7 +997,7 @@
 	guint32 lhost = htonl(127 * 256 * 256 * 256 + 1);
 	long unsigned int add;
 	int source = fd;
-	int len;
+	int len, count = 0;
 
 	if (fd < 0)
 		source = socket(PF_INET, SOCK_STREAM, 0);
@@ -1013,7 +1013,7 @@
 	memcpy(ip_ext, "0.0.0.0", 7);
 	tmp = buffer;
 	tip = ip_ext;
-	while (tmp < buffer + ifc.ifc_len)
+	while (tmp < buffer + ifc.ifc_len && count < 10)
 	{
 		ifr = (struct ifreq *)tmp;
 		tmp += HX_SIZE_OF_IFREQ(*ifr);
@@ -1030,6 +1030,7 @@
 					((add >> 8) & 255),
 					add & 255);
 				tip = (char*) ((int) tip + len);
+				count++;
 				continue;
 			}
 		}