summaryrefslogtreecommitdiffstats
path: root/stack/smp/smp_cmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'stack/smp/smp_cmac.c')
-rw-r--r--stack/smp/smp_cmac.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/stack/smp/smp_cmac.c b/stack/smp/smp_cmac.c
index 9ed295735..b0fdc0f1a 100644
--- a/stack/smp/smp_cmac.c
+++ b/stack/smp/smp_cmac.c
@@ -137,7 +137,7 @@ static BOOLEAN cmac_aes_k_calculate(BT_OCTET16 key, UINT8 *p_signature, UINT16 t
tSMP_ENC output;
UINT8 i = 1, err = 0;
UINT8 x[16] = {0};
- UINT8 *p_mac;
+ UINT8 *p_mac = NULL;
SMP_TRACE_EVENT ("cmac_aes_k_calculate ");
@@ -157,6 +157,8 @@ static BOOLEAN cmac_aes_k_calculate(BT_OCTET16 key, UINT8 *p_signature, UINT16 t
if (!err)
{
+ if (tlen > BT_OCTET16_LEN)
+ tlen = BT_OCTET16_LEN;
p_mac = output.param_buf + (BT_OCTET16_LEN - tlen);
memcpy(p_signature, p_mac, tlen);