vdev_draid_lookup_map() should not iterate outside draid_maps

Coverity reported this as an out-of-bounds read.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13865
This commit is contained in:
Richard Yao 2022-09-12 15:51:17 -04:00 committed by GitHub
parent 7195c04d98
commit e5327e7f97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -541,7 +541,7 @@ vdev_draid_generate_perms(const draid_map_t *map, uint8_t **permsp)
int int
vdev_draid_lookup_map(uint64_t children, const draid_map_t **mapp) vdev_draid_lookup_map(uint64_t children, const draid_map_t **mapp)
{ {
for (int i = 0; i <= VDEV_DRAID_MAX_MAPS; i++) { for (int i = 0; i < VDEV_DRAID_MAX_MAPS; i++) {
if (draid_maps[i].dm_children == children) { if (draid_maps[i].dm_children == children) {
*mapp = &draid_maps[i]; *mapp = &draid_maps[i];
return (0); return (0);