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:	2d67f2bae3
Pull Request: https://github.com/freebsd/freebsd-src/pull/581
This commit is contained in:
Jose Luis Duran 2022-02-25 11:47:53 -03:00 committed by Warner Losh
parent bff83dd395
commit 81a659e364

View File

@ -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;