]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
fix potential int overflow in efi/boot
authorStefano Stabellini <stefano@aporeto.com>
Fri, 9 Dec 2016 19:52:09 +0000 (11:52 -0800)
committerStefano Stabellini <sstabellini@kernel.org>
Mon, 12 Dec 2016 19:01:54 +0000 (11:01 -0800)
HorizontalResolution and VerticalResolution are 32bit, while size is
64bit. As it stands multiplications are evaluated with 32bit arithmetic,
which could overflow. Cast HorizontalResolution to 64bit to avoid that.

Coverity-ID: 1381858

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/common/efi/boot.c

index 56544dcb66d1042e16556c5f7b5e9322c13c4e45..3e5e4ab0e9336c2b257fdd0b295fc8d6de128e55 100644 (file)
@@ -684,10 +684,10 @@ static UINTN __init efi_find_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop,
             break;
         }
         if ( !cols && !rows &&
-             mode_info->HorizontalResolution *
+             (UINTN)mode_info->HorizontalResolution *
              mode_info->VerticalResolution > size )
         {
-            size = mode_info->HorizontalResolution *
+            size = (UINTN)mode_info->HorizontalResolution *
                    mode_info->VerticalResolution;
             gop_mode = i;
         }