diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2016-05-03 22:16:58 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2016-05-03 22:17:24 +0200 |
commit | 5a55d117dac9c36b075d6843bbcedabc32af0c52 (patch) | |
tree | 066e885c4323b2a0f97841f0947bb45b5f1b2593 /src | |
parent | 0ac5e3f0bef13c8b2d5f8f947100567aa4b13685 (diff) | |
download | fastd-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.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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) { |