File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
subsys/bluetooth/mesh/shell Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,26 @@ static void rpr_scan_report(struct bt_mesh_rpr_cli *cli,
38
38
uint8_t len , type ;
39
39
uint8_t data [31 ];
40
40
41
- len = net_buf_simple_pull_u8 (adv_data ) - 1 ;
41
+ len = net_buf_simple_pull_u8 (adv_data );
42
+ if (len == 0 ) {
43
+ /* No data in this AD Structure. */
44
+ continue ;
45
+ }
46
+
47
+ if (len > adv_data -> len ) {
48
+ /* Malformed AD Structure. */
49
+ break ;
50
+ }
51
+
42
52
type = net_buf_simple_pull_u8 (adv_data );
43
- memcpy (data , net_buf_simple_pull_mem (adv_data , len ), len );
53
+ if ((-- len ) > 0 ) {
54
+ uint8_t dlen ;
55
+
56
+ /* Pull all length, but print only what fits into `data` array. */
57
+ dlen = MIN (len , sizeof (data ) - 1 );
58
+ memcpy (data , net_buf_simple_pull_mem (adv_data , len ), dlen );
59
+ len = dlen ;
60
+ }
44
61
data [len ] = '\0' ;
45
62
46
63
if (type == BT_DATA_URI ) {
You can’t perform that action at this time.
0 commit comments