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 <imp@bsdimp.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>
Reviewed-by: Warner Losh <imp@bsdimp.com>
This commit is contained in:
@@ -2581,7 +2581,14 @@ DevPathFromTextiSCSI (
|
|||||||
|
|
||||||
ISCSIDevPath->LoginOption = (UINT16) Options;
|
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;
|
return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user