svn commit: r336653 - in head/stand/efi: include libefi

Warner Losh imp at FreeBSD.org
Mon Jul 23 20:36:49 UTC 2018


Author: imp
Date: Mon Jul 23 20:36:45 2018
New Revision: 336653
URL: https://svnweb.freebsd.org/changeset/base/336653

Log:
  Implement efi_devpath_match_node
  
  Returns true if the first node pointed to by devpath1 is identical to
  the first node pointed to by devpath2, with care taken to not read
  past the end of the valid parts of either devpath1 or
  devpath2. Otherwise, returns false.
  
  Sponsored by: Netflix

Modified:
  head/stand/efi/include/efilib.h
  head/stand/efi/libefi/devpath.c

Modified: head/stand/efi/include/efilib.h
==============================================================================
--- head/stand/efi/include/efilib.h	Mon Jul 23 20:36:41 2018	(r336652)
+++ head/stand/efi/include/efilib.h	Mon Jul 23 20:36:45 2018	(r336653)
@@ -85,6 +85,7 @@ EFI_HANDLE efi_devpath_handle(EFI_DEVICE_PATH *);
 EFI_DEVICE_PATH *efi_devpath_last_node(EFI_DEVICE_PATH *);
 EFI_DEVICE_PATH *efi_devpath_trim(EFI_DEVICE_PATH *);
 bool efi_devpath_match(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
+bool efi_devpath_match_node(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
 bool efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
 CHAR16 *efi_devpath_name(EFI_DEVICE_PATH *);
 void efi_free_devpath_name(CHAR16 *);

Modified: head/stand/efi/libefi/devpath.c
==============================================================================
--- head/stand/efi/libefi/devpath.c	Mon Jul 23 20:36:41 2018	(r336652)
+++ head/stand/efi/libefi/devpath.c	Mon Jul 23 20:36:45 2018	(r336653)
@@ -140,25 +140,33 @@ efi_devpath_handle(EFI_DEVICE_PATH *devpath)
 }
 
 bool
-efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2)
+efi_devpath_match_node(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2)
 {
 	size_t len;
 
 	if (devpath1 == NULL || devpath2 == NULL)
 		return (false);
+	if (DevicePathType(devpath1) != DevicePathType(devpath2) ||
+	    DevicePathSubType(devpath1) != DevicePathSubType(devpath2))
+		return (false);
+	len = DevicePathNodeLength(devpath1);
+	if (len != DevicePathNodeLength(devpath2))
+		return (false);
+	if (memcmp(devpath1, devpath2, len) != 0)
+		return (false);
+	return (true);
+}
 
-	while (true) {
-		if (DevicePathType(devpath1) != DevicePathType(devpath2) ||
-		    DevicePathSubType(devpath1) != DevicePathSubType(devpath2))
-			return (false);
+bool
+efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2)
+{
 
-		len = DevicePathNodeLength(devpath1);
-		if (len != DevicePathNodeLength(devpath2))
-			return (false);
+	if (devpath1 == NULL || devpath2 == NULL)
+		return (false);
 
-		if (memcmp(devpath1, devpath2, len) != 0)
-			return (false);
-
+	while (true) {
+		if (!efi_devpath_match_node(devpath1, devpath2))
+			return false;
 		if (IsDevicePathEnd(devpath1))
 			break;
 		devpath1 = NextDevicePathNode(devpath1);


More information about the svn-src-head mailing list