From 2403d8a285ddb5883d044c720ee45c2e3a775cc2 Mon Sep 17 00:00:00 2001 From: banzhuan Date: Sat, 6 Oct 2018 11:24:18 +0800 Subject: [PATCH] mesh: Fix the wrong way to detect the trailing space. Assignment n bytes to link.rx.buf->om_len will lead to n bytes decrease of OS_MBUF_TRAILINGSPACE(link.rx.buf), so we should get the OS_MBUF_TRAILINGSPACE(link.rx.buf) before assignment net_buf_simple_pull_be16(buf) to link.rx.buf->om_len. --- 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 cb6123184..f9830d349 100644 --- a/nimble/host/mesh/src/prov.c +++ b/nimble/host/mesh/src/prov.c @@ -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; @@ -1386,7 +1388,7 @@ static void gen_prov_start(struct prov_rx *rx, struct os_mbuf *buf) return; } - u16_t trailing_space = OS_MBUF_TRAILINGSPACE(link.rx.buf); + 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;