mesh/prov.c: change order of checks in prov_msg_recv()
First, PDU type should be checked first and then if PDU is valid. Otherwise,
we'll never check if PDU type is valid, and always return PROV_ERR_UNEXP_PDU.
If PDU type isn't valid, PROV_ERR_NVAL_FMT shall be returned (0x02).
@@ -1616,15 +1616,15 @@ static void prov_msg_recv(void)
return;
}
- if (type != PROV_FAILED && type != link.expect) {
- BT_WARN("Unexpected msg 0x%02x != 0x%02x", type, link.expect);
- prov_send_fail_msg(PROV_ERR_UNEXP_PDU);
+ if (type >= ARRAY_SIZE(prov_handlers)) {
+ BT_ERR("Unknown provisioning PDU type 0x%02x", type);
+ prov_send_fail_msg(PROV_ERR_NVAL_FMT);
return;
}
- if (type >= ARRAY_SIZE(prov_handlers)) {
- BT_ERR("Unknown provisioning PDU type 0x%02x", type);
- prov_send_fail_msg(PROV_ERR_NVAL_PDU);
+ if (type != PROV_FAILED && type != link.expect) {
+ BT_WARN("Unexpected msg 0x%02x != 0x%02x", type, link.expect);
+ prov_send_fail_msg(PROV_ERR_UNEXP_PDU);
return;
}
