Mercurial > pidgin.yaz
comparison libpurple/protocols/bonjour/jabber.c @ 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 | da75dd6c41fb |
children | 577d90f8794e |
comparison
equal
deleted
inserted
replaced
21462:31fc6a0769ce | 21463:2b6553584385 |
---|---|
995 struct ifreq *ifr; | 995 struct ifreq *ifr; |
996 struct sockaddr_in *sinptr; | 996 struct sockaddr_in *sinptr; |
997 guint32 lhost = htonl(127 * 256 * 256 * 256 + 1); | 997 guint32 lhost = htonl(127 * 256 * 256 * 256 + 1); |
998 long unsigned int add; | 998 long unsigned int add; |
999 int source = fd; | 999 int source = fd; |
1000 int len; | 1000 int len, count = 0; |
1001 | 1001 |
1002 if (fd < 0) | 1002 if (fd < 0) |
1003 source = socket(PF_INET, SOCK_STREAM, 0); | 1003 source = socket(PF_INET, SOCK_STREAM, 0); |
1004 | 1004 |
1005 ifc.ifc_len = sizeof(buffer); | 1005 ifc.ifc_len = sizeof(buffer); |
1011 | 1011 |
1012 memset(ip_ext, 0, sizeof(ip_ext)); | 1012 memset(ip_ext, 0, sizeof(ip_ext)); |
1013 memcpy(ip_ext, "0.0.0.0", 7); | 1013 memcpy(ip_ext, "0.0.0.0", 7); |
1014 tmp = buffer; | 1014 tmp = buffer; |
1015 tip = ip_ext; | 1015 tip = ip_ext; |
1016 while (tmp < buffer + ifc.ifc_len) | 1016 while (tmp < buffer + ifc.ifc_len && count < 10) |
1017 { | 1017 { |
1018 ifr = (struct ifreq *)tmp; | 1018 ifr = (struct ifreq *)tmp; |
1019 tmp += HX_SIZE_OF_IFREQ(*ifr); | 1019 tmp += HX_SIZE_OF_IFREQ(*ifr); |
1020 | 1020 |
1021 if (ifr->ifr_addr.sa_family == AF_INET) | 1021 if (ifr->ifr_addr.sa_family == AF_INET) |
1028 ((add >> 24) & 255), | 1028 ((add >> 24) & 255), |
1029 ((add >> 16) & 255), | 1029 ((add >> 16) & 255), |
1030 ((add >> 8) & 255), | 1030 ((add >> 8) & 255), |
1031 add & 255); | 1031 add & 255); |
1032 tip = (char*) ((int) tip + len); | 1032 tip = (char*) ((int) tip + len); |
1033 count++; | |
1033 continue; | 1034 continue; |
1034 } | 1035 } |
1035 } | 1036 } |
1036 } | 1037 } |
1037 | 1038 |