]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enhance the parameter check to avoid potential issue in negotiation.
authorYe Ting <ting.ye@intel.com>
Wed, 4 Feb 2015 08:53:56 +0000 (08:53 +0000)
committertye1 <tye1@Edk2>
Wed, 4 Feb 2015 08:53:56 +0000 (08:53 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Tian Feng <feng.tian@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16750 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c

index b2bf9466c169386783515de6ad5caa3deaf26f20..1ac79e7ca179701ab6f7f37918c9e0fb8b788c24 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of iSCSI protocol based on RFC3720.\r
 \r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1225,12 +1225,14 @@ IScsiCheckOpParams (
   //\r
   // InitialR2T, result function is OR.\r
   //\r
-  Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);\r
-  if (Value == NULL) {\r
-    goto ON_ERROR;\r
-  }\r
+  if (!Session->InitialR2T) {\r
+    Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);\r
+    if (Value == NULL) {\r
+      goto ON_ERROR;\r
+    }\r
 \r
-  Session->InitialR2T = (BOOLEAN) (Session->InitialR2T || (AsciiStrCmp (Value, "Yes") == 0));\r
+    Session->InitialR2T = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);\r
+  }\r
 \r
   //\r
   // ImmediateData, result function is AND.\r
@@ -1240,7 +1242,7 @@ IScsiCheckOpParams (
     goto ON_ERROR;\r
   }\r
 \r
-  Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (AsciiStrCmp (Value, "Yes") == 0));\r
+  Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0));\r
 \r
   //\r
   // MaxRecvDataSegmentLength is declarative.\r
@@ -1265,13 +1267,15 @@ IScsiCheckOpParams (
   // ImmediateData=No.\r
   // This Key/Value is negotiation type.\r
   //\r
-  Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);\r
-  if (Value == NULL) {\r
-    goto ON_ERROR;\r
-  }\r
+  if (!(Session->InitialR2T && !Session->ImmediateData)) {\r
+    Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);\r
+    if (Value == NULL) {\r
+      goto ON_ERROR;\r
+    }\r
 \r
-  NumericValue              = AsciiStrDecimalToUintn (Value);\r
-  Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength, NumericValue);\r
+    NumericValue              = AsciiStrDecimalToUintn (Value);\r
+    Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength, NumericValue);\r
+  }\r
 \r
   //\r
   // MaxConnections, result function is Minimum.\r
@@ -1360,7 +1364,7 @@ IScsiCheckOpParams (
   Session->MaxOutstandingR2T = (UINT16) MIN (Session->MaxOutstandingR2T, NumericValue);\r
 \r
   //\r
-  // Remove declarative key-value paris if any.\r
+  // Remove declarative key-value pairs, if any.\r
   //\r
   IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_SESSION_TYPE);\r
   IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ALIAS);\r
@@ -1368,9 +1372,17 @@ IScsiCheckOpParams (
   //\r
   // Remove the key-value that may not needed for result function is OR.\r
   //\r
+  IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);\r
   IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_PDU_IN_ORDER);\r
   IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_SEQUENCE_IN_ORDER);\r
 \r
+  //\r
+  // Remove irrelevant parameter, if any.\r
+  //\r
+  if (Session->InitialR2T && !Session->ImmediateData) {\r
+    IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);\r
+  }\r
+\r
   if (IsListEmpty (KeyValueList)) {\r
     //\r
     // Succeed if no more keys in the list.\r