ipsec: fix integer overflow 74/41274/2
authorFan Zhang <fanzhang.oss@gmail.com>
Wed, 17 Jul 2024 15:08:12 +0000 (16:08 +0100)
committerMatthew Smith <mgsmith@netgate.com>
Fri, 19 Jul 2024 12:24:22 +0000 (12:24 +0000)
Type: fix
Coverity issue: 394440

Change-Id: I915a088145ee1317a7c8746b517f4af50323aa11
Signed-off-by: Fan Zhang <fanzhang.oss@gmail.com>
src/vnet/ipsec/ipsec_sa.h

index 4f73f1e..640d928 100644 (file)
@@ -486,7 +486,7 @@ ipsec_sa_anti_replay_and_sn_advance (const ipsec_sa_t *sa, u32 seq,
       return 0;
     }
 
-  if (PREDICT_TRUE (sa->seq >= window_size - 1))
+  if (PREDICT_TRUE (window_size > 0 && sa->seq >= window_size - 1))
     {
       /*
        * the last sequence number VPP received is more than one