CollisionPrevention: prevent illegal array index with malicious obstacle_dsitance message

This commit is contained in:
Matthias Grob 2024-11-20 10:47:02 +01:00 committed by Claudio Chies
parent 1410325c62
commit bbc59dcde7

View File

@ -234,7 +234,7 @@ void CollisionPrevention::_addObstacleSensorData(const obstacle_distance_s &obst
// Obstacle message arrives in local_origin frame (north aligned)
// corresponding data index (convert to world frame and shift by msg offset)
for (int i = 0; i < BIN_COUNT; i++) {
for (int j = 0; j < 360 / obstacle.increment; j++) {
for (int j = 0; (j < 360 / obstacle.increment) && (j < BIN_COUNT); j++) {
float bin_lower_angle = _wrap_360((float)i * _obstacle_map_body_frame.increment + _obstacle_map_body_frame.angle_offset
- (float)_obstacle_map_body_frame.increment / 2.f);
float bin_upper_angle = _wrap_360((float)i * _obstacle_map_body_frame.increment + _obstacle_map_body_frame.angle_offset