]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/DevicePathFromText: Fix byte orders of iSCSI.Lun
authorRuiyu Ni <ruiyu.ni@intel.com>
Fri, 2 Mar 2018 11:50:30 +0000 (19:50 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Sat, 3 Mar 2018 07:12:50 +0000 (15:12 +0800)
Per UEFI spec, iSCSI.Lun is a 8-byte array with byte #0 in the left.
It means "0102030405060708" should be converted to:
    UINT8[8] = {01, 02, 03, 04, 05, 06, 07, 08}
or  UINT64 = {0807060504030201}

Today's implementation wrongly uses the reversed order.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jie Lin <jie.lin@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c

index c66b77ba6c69a902cac63de0d96183ee35c15fcd..35a73e83ff2181e067a212d2e67f630c809b3b81 100644 (file)
@@ -2542,6 +2542,7 @@ DevPathFromTextiSCSI (
   CHAR16                      *ProtocolStr;\r
   CHAR8                       *AsciiStr;\r
   ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
+  UINT64                      Lun;\r
 \r
   NameStr           = GetNextParamStr (&TextDeviceNode);\r
   PortalGroupStr    = GetNextParamStr (&TextDeviceNode);\r
@@ -2560,7 +2561,8 @@ DevPathFromTextiSCSI (
   StrToAscii (NameStr, &AsciiStr);\r
 \r
   ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);\r
-  Strtoi64 (LunStr, &ISCSIDevPath->Lun);\r
+  Strtoi64 (LunStr, &Lun);\r
+  WriteUnaligned64 ((UINT64 *) &ISCSIDevPath->Lun, SwapBytes64 (Lun));\r
 \r
   Options = 0x0000;\r
   if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r