]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dcerpc: use wrappingadd for padding parsing
authorPhilippe Antoine <contact@catenacyber.fr>
Sat, 2 Apr 2022 19:41:56 +0000 (21:41 +0200)
committerJeff Lucovsky <jeff@lucovsky.org>
Fri, 27 May 2022 11:51:21 +0000 (07:51 -0400)
As we compute a modulo, we can safely wrap around even if there
is an overflow

Ticket: #5301
(cherry picked from commit d2f00ac824068475414a6ee402c9ecf4b0de1308)

rust/src/dcerpc/parser.rs

index 9771a28be0cb117f8adebf0a544003191e8beb10..4110d03239f435326b7cd76d8627b03ef7902321 100644 (file)
@@ -160,7 +160,7 @@ named!(pub parse_dcerpc_bindack<DCERPCBindAck>,
         >> _assoc_group: take!(4)
         >> sec_addr_len: le_u16
         >> take!(sec_addr_len)
-        >> cond!((sec_addr_len + 2) % 4 != 0, take!(4 - (sec_addr_len + 2) % 4))
+        >> cond!((sec_addr_len.wrapping_add(2)) % 4 != 0, take!(4 - (sec_addr_len.wrapping_add(2)) % 4))
         >> numctxitems: le_u8
         >> take!(3) // Padding
         >> ctxitems: count!(parse_dcerpc_bindack_result, numctxitems as usize)