Skip to content

Commit

Permalink
FW-449. Fixing overflow in DAGrank calculation
Browse files Browse the repository at this point in the history
In the calculation of the tentativeDAGrank in
neighbors_updateMyDAGrankAndNeighborPreference an overflow was possible.
This results in occasional choosing a preferred parent with MAXDAGRANK.
  • Loading branch information
koalo committed Mar 10, 2016
1 parent f179a2d commit 499d915
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion openstack/02b-MAChigh/neighbors.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ void neighbors_updateMyDAGrankAndNeighborPreference() {
rankIncrease = (uint16_t)(rankIncreaseIntermediary >> 10);
}

tentativeDAGrank = neighbors_vars.neighbors[i].DAGrank+rankIncrease;
// cast the uint16_t summands to avoid an overflow if DAGrank == 0xFFFF (MAXDAGRANK)
tentativeDAGrank = (uint32_t)neighbors_vars.neighbors[i].DAGrank + (uint32_t)rankIncrease;
if ( tentativeDAGrank<neighbors_vars.myDAGrank &&
tentativeDAGrank<MAXDAGRANK) {
// found better parent, lower my DAGrank
Expand Down

0 comments on commit 499d915

Please sign in to comment.