Check whether you've hit the end of the packet data before going further.

If we found no bytes with the low-order bit set in the packet data,
there's no point in checking the non-existent "next" byte to see if it's
a HDLC-style UI control byte (0x03).

Bug: 15463
Change-Id: Ibfd186e5b81d8ce229362e23f00b31a27900831a
Reviewed-on: https://code.wireshark.org/review/31824
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2019-01-30 23:39:54 -08:00
parent 2a675c0d5b
commit 498b64c95c
1 changed files with 3 additions and 2 deletions

View File

@ -1783,13 +1783,14 @@ infer_pkt_encap(const guint8 *pd, int len)
*/
for (i = 0; i < len && (pd[i] & 0x01) == 0; i++)
;
i++; /* advance to the byte after the last DLCI byte */
if (i == len) {
/*
* No control byte.
* No control byte - all the bytes have the
* low-order bit clear.
*/
return WTAP_ENCAP_LAPB;
}
i++; /* advance to the byte after the last DLCI byte */
if (pd[i] == 0x03)
return WTAP_ENCAP_FRELAY_WITH_PHDR;
}