Skip to content

Commit 037568d

Browse files
committed
host tests: Fix test that accessed unspecified memory
Depending on compiler optimization and version ble_att_svr_test_read_mult() could rise error: In function ‘memcpy’, inlined from ‘TEST_CASE_ble_att_svr_test_read_mult’ at repos/apache-mynewt-nimble/nimble/host/test/src/ble_att_svr_test.c:1027:5: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: error: ‘__builtin_memcpy’ forming offset [18, 19] is out of the bounds [0, 18] of object ‘({anonymous})’ with type ‘uint8_t[18]’ {aka ‘unsigned char[18]’} [-Werror=array-bounds=] 29 | return __builtin___memcpy_chk (__dest, __src, __len, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 30 | __glibc_objsize0 (__dest)); array was clearly to short for memcpy and later data with 20 bytes had 2 unspecified values at the end Signed-off-by: Jerzy Kasenberg <[email protected]>
1 parent 5d07ffe commit 037568d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

nimble/host/test/src/ble_att_svr_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ TEST_CASE_SELF(ble_att_svr_test_read_mult)
10261026
attrs[1].value_len = 20;
10271027
memcpy(attrs[1].value,
10281028
((uint8_t[]){
1029-
22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39
1029+
20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39
10301030
}),
10311031
attrs[1].value_len);
10321032
ble_att_svr_test_attr_r_2_len = attrs[1].value_len;

0 commit comments

Comments
 (0)