mirror of
https://git.proxmox.com/git/efi-boot-shim
synced 2025-08-15 12:12:27 +00:00
shim: Improve the bounds checking of ImageAddress()
Make ImageAddress() directly check for overflow in its math. Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
parent
91e5f5324e
commit
568dc4944f
10
shim.c
10
shim.c
@ -50,6 +50,8 @@
|
||||
|
||||
#include <Library/BaseCryptLib.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define FALLBACK L"\\fb" EFI_ARCH L".efi"
|
||||
#define MOK_MANAGER L"\\mm" EFI_ARCH L".efi"
|
||||
|
||||
@ -111,11 +113,17 @@ typedef struct {
|
||||
/*
|
||||
* Perform basic bounds checking of the intra-image pointers
|
||||
*/
|
||||
static void *ImageAddress (void *image, unsigned int size, unsigned int address)
|
||||
static void *ImageAddress (void *image, uint64_t size, uint64_t address)
|
||||
{
|
||||
/* ensure our local pointer isn't bigger than our size */
|
||||
if (address > size)
|
||||
return NULL;
|
||||
|
||||
/* Insure our math won't overflow */
|
||||
if (UINT64_MAX - address < (uint64_t)image)
|
||||
return NULL;
|
||||
|
||||
/* return the absolute pointer */
|
||||
return image + address;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user