svn commit: r340019 - stable/12/stand/efi/loader

Warner Losh imp at FreeBSD.org
Thu Nov 1 21:28:23 UTC 2018


Author: imp
Date: Thu Nov  1 21:28:22 2018
New Revision: 340019
URL: https://svnweb.freebsd.org/changeset/base/340019

Log:
  MFC: r339800 and r339802:
  
  Fixes to ignore partial DEVICE_PATH items in  BOOT_PARAM objects that are
  too short.
  
  Approved by:	re@ (glen)

Modified:
  stable/12/stand/efi/loader/main.c

Modified: stable/12/stand/efi/loader/main.c
==============================================================================
--- stable/12/stand/efi/loader/main.c	Thu Nov  1 21:25:26 2018	(r340018)
+++ stable/12/stand/efi/loader/main.c	Thu Nov  1 21:28:22 2018	(r340019)
@@ -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) {
+	while (dp < edp && SIZE(dp, edp) > sizeof(EFI_DEVICE_PATH)) {
 		text = efi_devpath_name(dp);
 		if (text != NULL) {
 			printf("   BootInfo Path: %S\n", text);


More information about the svn-src-stable-12 mailing list