From 7ca6daff6a43f11fb93831e0970fb8bfb5d0833a Mon Sep 17 00:00:00 2001 From: Jose Luis Duran Date: Wed, 23 Feb 2022 22:43:27 -0300 Subject: [PATCH] libefivar: Refine the DevPathFromTextiSCSI protocol parsing For current iSCSI protocol parsing, UINT16 truncation may be happened. Since the Spec already have declaimed that 0 is TCP Protocol and 1+ is reserved, the parsing can be refined as below: if (StrCmp (ProtocolStr, L"TCP") == 0) { ISCSIDevPath->NetworkProtocol = 0; } else { // // Undefined and reserved. // ISCSIDevPath->NetworkProtocol = 1; } Obtained from: https://github.com/tianocore/edk2/commit/7571a1c191e19b48d33a33c8b7763b49999700ee Pull Request: https://github.com/freebsd/freebsd-src/pull/581 --- lib/libefivar/efivar-dp-parse.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/libefivar/efivar-dp-parse.c b/lib/libefivar/efivar-dp-parse.c index 82f9c6027d32..02c32971f4c6 100644 --- a/lib/libefivar/efivar-dp-parse.c +++ b/lib/libefivar/efivar-dp-parse.c @@ -2725,7 +2725,14 @@ DevPathFromTextiSCSI ( ISCSIDevPath->LoginOption = (UINT16) Options; - ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, "TCP"); + if (StrCmp (ProtocolStr, "TCP") == 0) { + ISCSIDevPath->NetworkProtocol = 0; + } else { + // + // Undefined and reserved. + // + ISCSIDevPath->NetworkProtocol = 1; + } return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath; }