Add the error checks in parsing, aimed to avoid parser walking past the end of packet in case the data
is garbage.
Type: fix
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Change-Id: I9541b555a18baf63cb8081bcd7a4c2750f2ed012
u32 len;
clib_memset (eid, 0, sizeof (*eid));
len = gid_address_parse (vlib_buffer_get_current (b), eid);
- if (len != ~0)
- vlib_buffer_pull (b, len);
- return len;
+ if ((len != ~0) && vlib_buffer_pull (b, len))
+ {
+ return len;
+ }
+ else
+ {
+ return ~0;
+ }
}
u32
return len;
gid_address_ippref_len (eid) = EID_REC_MLEN (h);
- vlib_buffer_pull (b, len + sizeof (eid_record_hdr_t));
+ if (!vlib_buffer_pull (b, len + sizeof (eid_record_hdr_t)))
+ {
+ return ~0;
+ }
return len + sizeof (eid_record_hdr_t);
}