summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ffd/neigh.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ffd/neigh.c b/ffd/neigh.c
index 74ff1b5..ca72ccc 100644
--- a/ffd/neigh.c
+++ b/ffd/neigh.c
@@ -55,7 +55,11 @@ uint16_t ffd_neigh_get_rxcost(const ffd_neigh_t *neigh) {
int timediff = timespec_diff(&now, &neigh->last_hello);
int shift = (timediff - neigh->hello_interval/2)/neigh->hello_interval;
- int received = __builtin_popcount(neigh->hello_log << shift);
+
+ if (shift >= 16)
+ return 0xffff;
+
+ int received = __builtin_popcount((neigh->hello_log << shift) & 0xffff);
if (received == 0)
return 0xffff;