]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/UefiDevicePathLib: Refine the DevPathFromTextiSCSI protocol parsing
authorJiaxin Wu <jiaxin.wu@intel.com>
Fri, 24 Mar 2017 01:53:50 +0000 (09:53 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Thu, 30 Mar 2017 03:32:24 +0000 (11:32 +0800)
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>
MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c

index 3c9df289b6d91a012ffdcb5cdd4baa4ef91a29b5..4322b6c0f28cf0903e321a97a058546afe55677b 100644 (file)
@@ -2581,7 +2581,14 @@ DevPathFromTextiSCSI (
 \r
   ISCSIDevPath->LoginOption      = (UINT16) Options;\r
 \r
-  ISCSIDevPath->NetworkProtocol  = (UINT16) StrCmp (ProtocolStr, L"TCP");\r
+  if (StrCmp (ProtocolStr, L"TCP") == 0) {\r
+    ISCSIDevPath->NetworkProtocol = 0;\r
+  } else {\r
+    //\r
+    // Undefined and reserved.\r
+    //\r
+    ISCSIDevPath->NetworkProtocol = 1;\r
+  }\r
 \r
   return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;\r
 }\r