The parsed 'length' field might pointsbeyond the end of the frame, for
some malformed frames. I haven't figured the source of said packets (I'm
using kernel 4.14.177, FWIW), but we can at least be safer about our
handling of them here.
Signed-off-by: Brian Norris <briannorris@chromium.org>
def sae_rx_commit_token_req(sock, radiotap, send_two=False):
msg = sock.recv(1500)
- ver, pad, len, present = struct.unpack('<BBHL', msg[0:8])
- frame = msg[len:]
+ ver, pad, length, present = struct.unpack('<BBHL', msg[0:8])
+ frame = msg[length:]
+ if len(frame) < 4:
+ return False
fc, duration = struct.unpack('<HH', frame[0:4])
if fc != 0xb0:
return False