diff options
author | Warner Losh <imp@FreeBSD.org> | 2018-10-26 23:44:50 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2018-10-26 23:44:50 +0000 |
commit | 48f0136d520c8d6d152074f70328af453162fda4 (patch) | |
tree | 9984d323e9e9cf897c587d2ddef9a98a28c288b4 /stand/efi | |
parent | 92f9212ba6ab4a7fc1265883eb3292d42e6dde9b (diff) | |
download | src-48f0136d520c8d6d152074f70328af453162fda4.tar.gz src-48f0136d520c8d6d152074f70328af453162fda4.zip |
Fix pointer arithmetic
Pointer math to find the size in bytes only works with char types.
Use correct pointer math to determine if we have enough of a header to
look at or not.
MFC After: 3 days
X-MFX-With: r339800
Noticed by: jhb@
Sponsored by: Netflix, Inc
Notes
Notes:
svn path=/head/; revision=339802
Diffstat (limited to 'stand/efi')
-rw-r--r-- | stand/efi/loader/main.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index c47077233916..1aa5fb9e765c 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -298,6 +298,8 @@ fix_dosisms(char *p) } } +#define SIZE(dp, edp) (size_t)((intptr_t)(void *)edp - (intptr_t)(void *)dp) + enum { BOOT_INFO_OK = 0, BAD_CHOICE = 1, NOT_SPECIFIC = 2 }; static int match_boot_info(EFI_LOADED_IMAGE *img __unused, char *boot_info, size_t bisz) @@ -349,7 +351,7 @@ match_boot_info(EFI_LOADED_IMAGE *img __unused, char *boot_info, size_t bisz) edp = (EFI_DEVICE_PATH *)(walker + fplen); if ((char *)edp > ep) return NOT_SPECIFIC; - while (dp < edp && (size_t)(edp - dp) > sizeof(EFI_DEVICE_PATH)) { + while (dp < edp && SIZE(dp, edp) > sizeof(EFI_DEVICE_PATH)) { text = efi_devpath_name(dp); if (text != NULL) { printf(" BootInfo Path: %S\n", text); |