Skip to content

Commit

Permalink
drivers: video: ov5640: Fix bug out-of-bound buffer read
Browse files Browse the repository at this point in the history
Fix the out of bound buffer read by checking the lower-bound index
in the ov5640_enum_frmival function.

Signed-off-by: Trung Hieu Le <[email protected]>
  • Loading branch information
trunghieulenxp authored and kartben committed Nov 29, 2024
1 parent 401a8a2 commit ecd6c61
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/video/ov5640.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,7 @@ static int ov5640_enum_frmival(const struct device *dev, enum video_endpoint_id
break;
}
}

if (i == ARRAY_SIZE(modes) || fie->index > ARRAY_SIZE(ov5640_frame_rates) ||
if (i == ARRAY_SIZE(modes) || fie->index >= ARRAY_SIZE(ov5640_frame_rates) ||
ov5640_frame_rates[fie->index] > modes[i].max_frmrate) {
return -EINVAL;
}
Expand Down

0 comments on commit ecd6c61

Please sign in to comment.