Skip to content

Commit

Permalink
Fix ipv6 extension headers parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Zadamsa committed Jul 28, 2024
1 parent f616af2 commit 6388b77
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion input/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,14 @@ uint16_t skip_ipv6_ext_hdrs(const u_char *data_ptr, uint16_t data_len, Packet *p
struct ip6_ext *ext = (struct ip6_ext *) data_ptr;
uint8_t next_hdr = pkt->ip_proto;
uint16_t hdrs_len = 0;
uint16_t previous_hdrs_len = 0;

/* Skip/parse extension headers... */
while (1) {
if ((int)sizeof(struct ip6_ext) > data_len - hdrs_len) {
if ((int)sizeof(struct ip6_ext) > data_len - hdrs_len || previous_hdrs_len > hdrs_len) {
throw "Parser detected malformed packet";
}
previous_hdrs_len = hdrs_len;
if (next_hdr == IPPROTO_HOPOPTS ||
next_hdr == IPPROTO_DSTOPTS) {
hdrs_len += (ext->ip6e_len << 3) + 8;
Expand Down

0 comments on commit 6388b77

Please # to comment.