+ /*
+ * 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 = GET_BE_U_2(ext->len);
+ if (item_len <= 4)
+ goto trunc;
+
+ if (sa_length < item_len)
+ goto toolong;
+ ND_TCHECK_LEN(cp, item_len);
+
+ depth++;
+ ND_PRINT("\n");
+ for (i = 0; i < depth; i++)
+ ND_PRINT(" ");
+ ND_PRINT("(");
+ if (np == ISAKMP_NPTYPE_P) {
+ cp = ikev2_p_print(ndo, np, pcount, ext, item_len,
+ ep, depth);
+ if (cp == NULL) {
+ /* error, already reported */
+ return NULL;
+ }
+ } else {
+ ND_PRINT("%s", NPSTR(np));
+ cp += item_len;
+ }
+ ND_PRINT(")");
+ depth--;
+ sa_length -= item_len;
+ }
+ return cp;
+toolong:
+ /*
+ * Skip the rest of the SA.
+ */
+ cp += sa_length;
+ ND_PRINT(" [|%s]", NPSTR(tpay));
+ return cp;