hvmloader: use bound checking in get_module_entry

Coverity complains:

overflow_before_widen: Potentially overflowing expression
info->nr_modules * 32U with type unsigned int (32 bits, unsigned) is
evaluated using 32-bit arithmetic, and then used in a context that
expects an expression of type uint64_t (64 bits, unsigned).

The overflow is unlikely to happen in reality because we only expect a
few modules.

Fix that by converting the check to use bound checking to placate
Coverity.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Wei Liu committed 2016-08-22 14:20:19 +01:00
1 parent 80a59905fd
commit 94d3b9990b
1 file changed
+2 -2
+2 -2
View File
@@ -272,8 +272,8 @@ const struct hvm_modlist_entry *get_module_entry(
if ( !modlist ||
info->modlist_paddr > UINTPTR_MAX ||
(info->modlist_paddr + info->nr_modules * sizeof(*modlist) - 1)
> UINTPTR_MAX )
(UINTPTR_MAX - (uintptr_t)info->modlist_paddr) / sizeof(*modlist)
< info->nr_modules )
return NULL;
for ( i = 0; i < info->nr_modules; i++ )
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.