* [Patch] MdePkg/UefiDevicePathLib: Refine the DevPathFromTextiSCSI protocol parsing
@ 2017-03-24 6:44 Jiaxin Wu
0 siblings, 0 replies; only message in thread
From: Jiaxin Wu @ 2017-03-24 6:44 UTC (permalink / raw)
To: edk2-devel; +Cc: Warner Losh, Liming Gao, Ye Ting, Fu Siyuan, Wu Jiaxin
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 <imp@bsdimp.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
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 3c9df28..4322b6c 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -2579,11 +2579,18 @@ DevPathFromTextiSCSI (
Options |= 0x1000;
}
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;
}
/**
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-03-24 6:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-24 6:44 [Patch] MdePkg/UefiDevicePathLib: Refine the DevPathFromTextiSCSI protocol parsing Jiaxin Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox