Merge pull request #197 from forgithub123/master

mesh: Fix the wrong way to detect the trailing space
This commit is contained in:
Łukasz Rymanowski
2018-10-08 13:35:24 +02:00
committed by GitHub
+5 -1
View File
@@ -1375,6 +1375,8 @@ static void gen_prov_ack(struct prov_rx *rx, struct os_mbuf *buf)
static void gen_prov_start(struct prov_rx *rx, struct os_mbuf *buf)
{
u16_t trailing_space = 0;
if (link.rx.seg) {
BT_WARN("Got Start while there are unreceived segments");
return;
@@ -1385,6 +1387,8 @@ static void gen_prov_start(struct prov_rx *rx, struct os_mbuf *buf)
gen_prov_ack_send(rx->xact_id);
return;
}
trailing_space = OS_MBUF_TRAILINGSPACE(link.rx.buf);
link.rx.buf->om_len = net_buf_simple_pull_be16(buf);
link.rx.id = rx->xact_id;
@@ -1399,7 +1403,7 @@ static void gen_prov_start(struct prov_rx *rx, struct os_mbuf *buf)
return;
}
if (link.rx.buf->om_len > OS_MBUF_TRAILINGSPACE(link.rx.buf)) {
if (link.rx.buf->om_len > trailing_space) {
BT_ERR("Too large provisioning PDU (%u bytes)",
link.rx.buf->om_len);
close_link(PROV_ERR_NVAL_FMT, CLOSE_REASON_FAILED);