Skip to content

Commit 1637ba9

Browse files
alxelaxrlubos
authored andcommitted
[nrf fromtree] Bluetooth: Mesh: fix static oob zero padding
The sample in the Provisioning protocol spec chapter is in big endian. Static OOB value should append zeroes on the little endian platforms. Signed-off-by: Aleksandr Khromykh <[email protected]> (cherry picked from commit fcfc47b)
1 parent f144465 commit 1637ba9

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

subsys/bluetooth/mesh/prov_device.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ static void prov_start(const uint8_t *data)
160160
}
161161

162162
if (atomic_test_bit(bt_mesh_prov_link.flags, OOB_STATIC_KEY)) {
163-
memcpy(bt_mesh_prov_link.auth + 16 - bt_mesh_prov->static_val_len,
164-
bt_mesh_prov->static_val, bt_mesh_prov->static_val_len);
165-
(void)memset(bt_mesh_prov_link.auth, 0,
166-
sizeof(bt_mesh_prov_link.auth) - bt_mesh_prov->static_val_len);
163+
memcpy(bt_mesh_prov_link.auth, bt_mesh_prov->static_val,
164+
bt_mesh_prov->static_val_len);
165+
memset(bt_mesh_prov_link.auth + bt_mesh_prov->static_val_len, 0,
166+
sizeof(bt_mesh_prov_link.auth) - bt_mesh_prov->static_val_len);
167167
}
168168
}
169169

subsys/bluetooth/mesh/provisioner.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,11 +698,9 @@ int bt_mesh_auth_method_set_static(const uint8_t *static_val, uint8_t size)
698698

699699
prov_set_method(AUTH_METHOD_STATIC, 0, 0);
700700

701-
memcpy(bt_mesh_prov_link.auth + 16 - size, static_val, size);
702-
if (size < 16) {
703-
(void)memset(bt_mesh_prov_link.auth, 0,
704-
sizeof(bt_mesh_prov_link.auth) - size);
705-
}
701+
memcpy(bt_mesh_prov_link.auth, static_val, size);
702+
memset(bt_mesh_prov_link.auth + size, 0, sizeof(bt_mesh_prov_link.auth) - size);
703+
706704
return 0;
707705
}
708706

0 commit comments

Comments
 (0)