OSDN Git Service

Fix SMP_Encrypt for data shorter than 16 bytes
authorJakub Pawlowski <jpawlowski@google.com>
Mon, 18 Jun 2018 20:29:24 +0000 (13:29 -0700)
committerJakub Pawlowski <jpawlowski@google.com>
Mon, 18 Jun 2018 20:32:05 +0000 (20:32 +0000)
This bug was introduced in commit c3e7c878fe8495590f059547153bd77cdea322a6
osi_calloc was replaced with raw array, that is not wiped clean.

Change-Id: I57a4e7a26108ad4672d2dd2ff25028653c96ca1b

stack/smp/smp_keys.cc

index 11e4942..13a4b6c 100644 (file)
@@ -115,6 +115,7 @@ void smp_encrypt_data(BT_OCTET16 key, uint8_t* message, uint8_t length,
   if (length > SMP_ENCRYT_DATA_SIZE) length = SMP_ENCRYT_DATA_SIZE;
 
   uint8_t p_start[SMP_ENCRYT_DATA_SIZE * 4];
+  memset(p_start, 0, SMP_ENCRYT_DATA_SIZE * 4);
   p = p_start;
   ARRAY_TO_STREAM(p, message, length);             /* byte 0 to byte 15 */
   p_rev_data = p = p_start + SMP_ENCRYT_DATA_SIZE; /* start at byte 16 */