Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Nov 2018 21:28:22 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r340019 - stable/12/stand/efi/loader
Message-ID:  <201811012128.wA1LSM4p007840@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811012128.wA1LSM4p007840>