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:	7571a1c191
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
This commit is contained in:
Jose Luis Duran 2022-02-23 22:43:27 -03:00 committed by Warner Losh
parent b782b7884c
commit 7ca6daff6a

View File

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