git: 81a659e364e2 - main - libefivar: Fix the wrong MAC address length

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sun, 27 Feb 2022 16:47:34 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=81a659e364e2ee84dd3220c0f87fb9add8fbfbed

commit 81a659e364e2ee84dd3220c0f87fb9add8fbfbed
Author:     Jose Luis Duran <jlduran@gmail.com>
AuthorDate: 2022-02-25 14:47:53 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-02-27 16:11:55 +0000

    libefivar: Fix the wrong MAC address length
    
    Network interface type should be checked before the conversion between
    text device path node and MAC device path. Otherwise, the MAC text string
    can't be converted to the representation of a device node, which leads to
    the series failure of network HII configuration(e.g. IP, VLAN, HTTP Boot
    configuration in Network Device List).
    
    Obtained from:  https://github.com/tianocore/edk2/commit/2d67f2bae32040c77af8097a8ef1be272cb00e28
    Pull Request: https://github.com/freebsd/freebsd-src/pull/581
---
 lib/libefivar/efivar-dp-parse.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/libefivar/efivar-dp-parse.c b/lib/libefivar/efivar-dp-parse.c
index 3fc4fd8a62fd..4040b001708d 100644
--- a/lib/libefivar/efivar-dp-parse.c
+++ b/lib/libefivar/efivar-dp-parse.c
@@ -1920,6 +1920,10 @@ DevPathFromTextMAC (
   MACDevPath->IfType   = (UINT8) Strtoi (IfTypeStr);
 
   Length = sizeof (EFI_MAC_ADDRESS);
+  if (MACDevPath->IfType == 0x01 || MACDevPath->IfType == 0x00) {
+    Length = 6;
+  }
+
   StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);
 
   return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;