summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-05-03 22:16:58 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-05-03 22:17:24 +0200
commit5a55d117dac9c36b075d6843bbcedabc32af0c52 (patch)
tree066e885c4323b2a0f97841f0947bb45b5f1b2593 /src
parent0ac5e3f0bef13c8b2d5f8f947100567aa4b13685 (diff)
downloadfastd-5a55d117dac9c36b075d6843bbcedabc32af0c52.tar
fastd-5a55d117dac9c36b075d6843bbcedabc32af0c52.zip
peer: fix potential integer overflows in fastd_peer_eth_addr_add
Fix potential integer overflows in binary search.
Diffstat (limited to 'src')
-rw-r--r--src/peer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/peer.c b/src/peer.c
index a26d20c..1e64f5f 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -890,13 +890,13 @@ static int peer_eth_addr_cmp(const fastd_peer_eth_addr_t *addr1, const fastd_pee
/** Adds a MAC address to the sorted list of addresses associated with a peer (or updates the timeout of an existing entry) */
void fastd_peer_eth_addr_add(fastd_peer_t *peer, fastd_eth_addr_t addr) {
- int min = 0, max = VECTOR_LEN(ctx.eth_addrs);
+ size_t min = 0, max = VECTOR_LEN(ctx.eth_addrs);
if (peer && !fastd_peer_is_established(peer))
exit_bug("tried to learn ethernet address on non-established peer");
while (max > min) {
- int cur = (min+max)/2;
+ size_t cur = min + (max - min)/2;
int cmp = eth_addr_cmp(&addr, &VECTOR_INDEX(ctx.eth_addrs, cur).addr);
if (cmp == 0) {