Squashed commit of the following:
commit
4aadd43f4a78c1e78ef2c1847098f090b6502108
Author: Steven Baigal (sbaigal) <sbaigal@cisco.com>
Date: Fri Jun 7 15:51:43 2019 -0400
icmp4: verify checksum before the type validation
const ICMPHdr* const icmph = reinterpret_cast<const ICMPHdr*>(raw.data);
uint16_t len = 0;
+ if (SnortConfig::icmp_checksums())
+ {
+ uint16_t csum = checksum::cksum_add((const uint16_t*)icmph, raw.len);
+
+ if (csum && !codec.is_cooked())
+ {
+ stats.bad_ip4_cksum++;
+ snort.decode_flags |= DECODE_ERR_CKSUM_ICMP;
+ return false;
+ }
+ }
+
switch (icmph->type)
{
// fall through ...
break;
}
- if (SnortConfig::icmp_checksums())
- {
- uint16_t csum = checksum::cksum_add((const uint16_t*)icmph, raw.len);
-
- if (csum && !codec.is_cooked())
- {
- stats.bad_ip4_cksum++;
- snort.decode_flags |= DECODE_ERR_CKSUM_ICMP;
- return false;
- }
- }
-
len = icmp::ICMP_BASE_LEN;
switch (icmph->type)