diff --git a/fsm.c b/fsm.c index 460ba13b6d7434a57f7515538b74f04c20dc10ea..b90dee5f2afc8e118612d1a7231b6920346b4402 100644 --- a/fsm.c +++ b/fsm.c @@ -174,9 +174,10 @@ static int type_length[__PP_NR_MESSAGES_TYPES] = { static int fsm_unpack_verify_frame(struct pp_instance *ppi, 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]) return 1; /* too short */ if ((packet[1] & 0xf) != 2)