Commit 95d92a1b authored by Alessandro Rubini's avatar Alessandro Rubini

bugfix: we can't check 0-size frames

bug introduced in

   cc014e83 fsm: centralize checks on the frame
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent d17cb001
...@@ -174,9 +174,10 @@ static int type_length[__PP_NR_MESSAGES_TYPES] = { ...@@ -174,9 +174,10 @@ static int type_length[__PP_NR_MESSAGES_TYPES] = {
static int fsm_unpack_verify_frame(struct pp_instance *ppi, static int fsm_unpack_verify_frame(struct pp_instance *ppi,
uint8_t *packet, int plen) uint8_t *packet, int plen)
{ {
int msgtype; int msgtype = 0;
msgtype = packet[0] & 0xf; if (plen)
msgtype = packet[0] & 0xf;
if (msgtype >= __PP_NR_MESSAGES_TYPES || plen < type_length[msgtype]) if (msgtype >= __PP_NR_MESSAGES_TYPES || plen < type_length[msgtype])
return 1; /* too short */ return 1; /* too short */
if ((packet[1] & 0xf) != 2) if ((packet[1] & 0xf) != 2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment