]> git.baikalelectronics.ru Git - kernel.git/commit
net/xfrm/xfrm_replay: avoid division by zero
authorNickolai Zeldovich <nickolai@csail.mit.edu>
Thu, 17 Jan 2013 18:58:28 +0000 (13:58 -0500)
committerSteffen Klassert <steffen.klassert@secunet.com>
Fri, 18 Jan 2013 05:19:49 +0000 (06:19 +0100)
commitff29254beb5f5f9a3eccf0428e0d645a6bf447bc
tree973e37521d6c65eaba2313950ca22b7ca8bee0c4
parent17ed0d777fcf23c68f719936e46b552e6a15084e
net/xfrm/xfrm_replay: avoid division by zero

All of the xfrm_replay->advance functions in xfrm_replay.c check if
x->replay_esn->replay_window is zero (and return if so).  However,
one of them, xfrm_replay_advance_bmp(), divides by that value (in the
'%' operator) before doing the check, which can potentially trigger
a divide-by-zero exception.  Some compilers will also assume that the
earlier division means the value cannot be zero later, and thus will
eliminate the subsequent zero check as dead code.

This patch moves the division to after the check.

Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_replay.c