From 9152940944b6b31a25650426db614d15c6d784d2 Mon Sep 17 00:00:00 2001 From: banzhuan Date: Wed, 26 Sep 2018 23:23:12 +0800 Subject: [PATCH] Fix the wrong way to detect the trailing space --- nimble/host/mesh/src/prov.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nimble/host/mesh/src/prov.c b/nimble/host/mesh/src/prov.c index 5943f0d25..cb6123184 100644 --- a/nimble/host/mesh/src/prov.c +++ b/nimble/host/mesh/src/prov.c @@ -1385,6 +1385,8 @@ static void gen_prov_start(struct prov_rx *rx, struct os_mbuf *buf) gen_prov_ack_send(rx->xact_id); return; } + + u16_t 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 +1401,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);