- if (NPFUNC(np))
- cp = (*NPFUNC(np))(ext, ep, phase, doi, proto, depth);
- else {
+ /*
+ * Since we can't have a payload length of less than 4 bytes,
+ * we need to bail out here if the generic header is nonsensical
+ * or truncated, otherwise we could loop forever processing
+ * zero-length items or otherwise misdissect the packet.
+ */
+ item_len = ntohs(e.len);
+ if (item_len <= 4)
+ return NULL;
+
+ if (NPFUNC(np)) {
+ /*
+ * XXX - what if item_len is too short, or too long,
+ * for this payload type?
+ */
+ cp = (*NPFUNC(np))(ext, item_len, ep, phase, doi, proto, depth);
+ } else {