Skip to content

Commit

Permalink
depmod: Check amount of memories
Browse files Browse the repository at this point in the history
The code does not support 65535 or more modules. Since this value is
probably never reached, add a proper check after array building and
do not rely solely on an assert later in code path.

Signed-off-by: Tobias Stoeckmann <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Link: #158
Signed-off-by: Lucas De Marchi <[email protected]>
  • Loading branch information
stoeckmann authored and lucasdemarchi committed Oct 1, 2024
1 parent a1186fa commit ea16db2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/depmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,8 @@ static int depmod_modules_build_array(struct depmod *depmod)
if (err < 0)
return err;
}
if (depmod->modules.count >= UINT16_MAX)
return -ERANGE;

return 0;
}
Expand Down

0 comments on commit ea16db2

Please sign in to comment.