- if (EXTRACT_16BITS(&ap->htype) == 1 &&
- EXTRACT_16BITS(&ap->ptype) == ETHERTYPE_ATALK &&
- ap->halen == 6 && ap->palen == 4 )
- switch (EXTRACT_16BITS(&ap->op)) {
+ if (!ND_TTEST(*ap)) {
+ /* Just bail if we don't have the whole chunk. */
+ ND_PRINT((ndo, " [|aarp]"));
+ return;
+ }
+ if (length < sizeof(*ap)) {
+ ND_PRINT((ndo, " [|aarp %u]", length));
+ return;
+ }
+ if (EXTRACT_BE_U_2(ap->htype) == 1 &&
+ EXTRACT_BE_U_2(ap->ptype) == ETHERTYPE_ATALK &&
+ EXTRACT_U_1(ap->halen) == 6 && EXTRACT_U_1(ap->palen) == 4 )
+ switch (EXTRACT_BE_U_2(ap->op)) {