Author: imp Date: Fri Oct 26 23:44:50 2018 New Revision: 339802 URL: https://svnweb.freebsd.org/changeset/base/339802
Log: 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 Modified: head/stand/efi/loader/main.c Modified: head/stand/efi/loader/main.c ============================================================================== --- head/stand/efi/loader/main.c Fri Oct 26 23:44:39 2018 (r339801) +++ head/stand/efi/loader/main.c Fri Oct 26 23:44:50 2018 (r339802) @@ -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 * 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); _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"