- printf("%04x, ", EXTRACT_16BITS(ptr)); ptr++; /* Disconnect Code */
- printf("%04x ", EXTRACT_16BITS(ptr)); ptr++; /* Control Protocol Number */
- printf("%s", tok2str(l2tp_cc_direction2str,
- "Direction-#%u", *((u_char *)ptr++)));
+ if (length < 5) {
+ ND_PRINT((ndo, "AVP too short"));
+ return;
+ }
+ /* Disconnect Code */
+ ND_PRINT((ndo, "%04x, ", EXTRACT_BE_U_2(dat)));
+ dat += 2;
+ length -= 2;
+ /* Control Protocol Number */
+ ND_PRINT((ndo, "%04x ", EXTRACT_BE_U_2(dat)));
+ dat += 2;
+ length -= 2;
+ /* Direction */
+ ND_PRINT((ndo, "%s", tok2str(l2tp_cc_direction2str,
+ "Direction-#%u", EXTRACT_U_1(ptr))));
+ ptr++;
+ length--;