File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -2332,6 +2332,10 @@ struct bt_mesh_comp_p1_elem *bt_mesh_comp_p1_elem_pull(struct net_buf_simple *bu
2332
2332
elem -> nsig = net_buf_simple_pull_u8 (buf );
2333
2333
elem -> nvnd = net_buf_simple_pull_u8 (buf );
2334
2334
for (i = 0 ; i < elem -> nsig + elem -> nvnd ; i ++ ) {
2335
+ if (buf -> len < elem_size + 1 ) {
2336
+ return NULL ;
2337
+ }
2338
+
2335
2339
header = buf -> data [elem_size ];
2336
2340
cor_present = COR_PRESENT (header );
2337
2341
fmt = FMT (header );
@@ -2346,6 +2350,10 @@ struct bt_mesh_comp_p1_elem *bt_mesh_comp_p1_elem_pull(struct net_buf_simple *bu
2346
2350
elem_size += (1 + cor_present ) + (fmt + 1 ) * ext_item_cnt ;
2347
2351
}
2348
2352
2353
+ if (buf -> len < elem_size ) {
2354
+ return NULL ;
2355
+ }
2356
+
2349
2357
net_buf_simple_init_with_data (elem -> _buf ,
2350
2358
net_buf_simple_pull_mem (buf , elem_size ),
2351
2359
elem_size );
@@ -2372,9 +2380,17 @@ struct bt_mesh_comp_p1_model_item *bt_mesh_comp_p1_item_pull(
2372
2380
item -> ext_item_cnt = EXT_ITEM_CNT (header );
2373
2381
item_size = item -> ext_item_cnt * (item -> format + 1 );
2374
2382
if (item -> cor_present ) {
2383
+ if (elem -> _buf -> len < 1 ) {
2384
+ return NULL ;
2385
+ }
2386
+
2375
2387
item -> cor_id = net_buf_simple_pull_u8 (elem -> _buf );
2376
2388
}
2377
2389
2390
+ if (elem -> _buf -> len < item_size ) {
2391
+ return NULL ;
2392
+ }
2393
+
2378
2394
net_buf_simple_init_with_data (item -> _buf ,
2379
2395
net_buf_simple_pull_mem (elem -> _buf , item_size ),
2380
2396
item_size );
You can’t perform that action at this time.
0 commit comments