Bluetooth: Mesh: Fix response to Provisioning PDU with invalid type

Reverse the order of these checks because invalid PDU type will
never be expected. If PDU type is invalid we should respond with
error 0x0002 - Invalid format.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
This commit is contained in:
Michał Narajowski 2020-07-06 14:53:15 +02:00 committed by Ioannis Glaropoulos
commit 67ab8a3173

View file

@ -1064,15 +1064,15 @@ static void prov_recv(const struct prov_bearer *bearer, void *cb_data,
BT_DBG("type 0x%02x len %u", type, buf->len); BT_DBG("type 0x%02x len %u", type, buf->len);
if (type != PROV_FAILED && type != link.expect) { if (type >= ARRAY_SIZE(prov_handlers)) {
BT_WARN("Unexpected msg 0x%02x != 0x%02x", type, link.expect); BT_ERR("Unknown provisioning PDU type 0x%02x", type);
prov_fail(PROV_ERR_UNEXP_PDU); prov_fail(PROV_ERR_NVAL_FMT);
return; return;
} }
if (type >= ARRAY_SIZE(prov_handlers)) { if (type != PROV_FAILED && type != link.expect) {
BT_ERR("Unknown provisioning PDU type 0x%02x", type); BT_WARN("Unexpected msg 0x%02x != 0x%02x", type, link.expect);
prov_fail(PROV_ERR_NVAL_PDU); prov_fail(PROV_ERR_UNEXP_PDU);
return; return;
} }