summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-01-29 21:43:22 +0000
committerrubidium <rubidium@openttd.org>2008-01-29 21:43:22 +0000
commit3e90a16cfc6e184d35132d55d6a7f96ab1257bac (patch)
tree72d871047704ad92ec4d27a363c084febefa05ed
parentdbe2c7582d3b951bef79183dcbedfaaf39bf59be (diff)
downloadopenttd-3e90a16cfc6e184d35132d55d6a7f96ab1257bac.tar.xz
(svn r12017) -Fix: when you have more than 9 network interfaces you'll enter the wonderfull world of overflows.
-rw-r--r--src/network/network.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index b8a53feb5..bbb6bb833 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -404,6 +404,7 @@ static void NetworkFindIPs()
inaddr.s_addr = htonl(ip | ~netmask);
_broadcast_list[i] = inaddr.s_addr;
i++;
+ if (i == MAX_INTERFACES) break;
}
if (read < 0) {
break;
@@ -431,6 +432,7 @@ static void NetworkFindIPs()
if (ifa->ifa_broadaddr->sa_family != AF_INET) continue;
_broadcast_list[i] = ((struct sockaddr_in*)ifa->ifa_broadaddr)->sin_addr.s_addr;
i++;
+ if (i == MAX_INTERFACES) break;
}
freeifaddrs(ifap);
@@ -470,6 +472,7 @@ static void NetworkFindIPs()
_broadcast_list[i++] =
ifo[j].iiAddress.AddressIn.sin_addr.s_addr |
~ifo[j].iiNetmask.AddressIn.sin_addr.s_addr;
+ if (i == MAX_INTERFACES) break;
}
#else
ifconf.ifc_len = sizeof(buf);
@@ -493,6 +496,7 @@ static void NetworkFindIPs()
ioctl(sock, SIOCGIFBRDADDR, &r) != -1) {
_broadcast_list[i++] =
((struct sockaddr_in*)&r.ifr_broadaddr)->sin_addr.s_addr;
+ if (i == MAX_INTERFACES) break;
}
}