From 7571a1c191e19b48d33a33c8b7763b49999700ee Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Fri, 24 Mar 2017 09:53:50 +0800 Subject: [PATCH] MdePkg/UefiDevicePathLib: 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; } Cc: Warner Losh Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Warner Losh --- MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c index 3c9df289b6..4322b6c0f2 100644 --- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c @@ -2581,7 +2581,14 @@ DevPathFromTextiSCSI ( ISCSIDevPath->LoginOption = (UINT16) Options; - ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP"); + if (StrCmp (ProtocolStr, L"TCP") == 0) { + ISCSIDevPath->NetworkProtocol = 0; + } else { + // + // Undefined and reserved. + // + ISCSIDevPath->NetworkProtocol = 1; + } return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath; } -- 2.39.2