Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Enhance the parameter check to avoid potential issue in negotiation.
Browse files Browse the repository at this point in the history
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ye Ting <[email protected]> 
Reviewed-by: Tian Feng <[email protected]>
Reviewed-by: Fu Siyuan <[email protected]>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16750 6f19259b-4bc3-4df7-8a09-765794883524
  • Loading branch information
tye1 authored and tye1 committed Feb 4, 2015
1 parent 27c93c0 commit 57f2e11
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
The implementation of iSCSI protocol based on RFC3720.
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
Expand Down Expand Up @@ -1225,12 +1225,14 @@ IScsiCheckOpParams (
//
// InitialR2T, result function is OR.
//
Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);
if (Value == NULL) {
goto ON_ERROR;
}
if (!Session->InitialR2T) {
Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);
if (Value == NULL) {
goto ON_ERROR;
}

Session->InitialR2T = (BOOLEAN) (Session->InitialR2T || (AsciiStrCmp (Value, "Yes") == 0));
Session->InitialR2T = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
}

//
// ImmediateData, result function is AND.
Expand All @@ -1240,7 +1242,7 @@ IScsiCheckOpParams (
goto ON_ERROR;
}

Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (AsciiStrCmp (Value, "Yes") == 0));
Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0));

//
// MaxRecvDataSegmentLength is declarative.
Expand All @@ -1265,13 +1267,15 @@ IScsiCheckOpParams (
// ImmediateData=No.
// This Key/Value is negotiation type.
//
Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);
if (Value == NULL) {
goto ON_ERROR;
}
if (!(Session->InitialR2T && !Session->ImmediateData)) {
Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);
if (Value == NULL) {
goto ON_ERROR;
}

NumericValue = AsciiStrDecimalToUintn (Value);
Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength, NumericValue);
NumericValue = AsciiStrDecimalToUintn (Value);
Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength, NumericValue);
}

//
// MaxConnections, result function is Minimum.
Expand Down Expand Up @@ -1360,17 +1364,25 @@ IScsiCheckOpParams (
Session->MaxOutstandingR2T = (UINT16) MIN (Session->MaxOutstandingR2T, NumericValue);

//
// Remove declarative key-value paris if any.
// Remove declarative key-value pairs, if any.
//
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_SESSION_TYPE);
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ALIAS);
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_PORTAL_GROUP_TAG);
//
// Remove the key-value that may not needed for result function is OR.
//
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_PDU_IN_ORDER);
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_SEQUENCE_IN_ORDER);

//
// Remove irrelevant parameter, if any.
//
if (Session->InitialR2T && !Session->ImmediateData) {
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);
}

if (IsListEmpty (KeyValueList)) {
//
// Succeed if no more keys in the list.
Expand Down

0 comments on commit 57f2e11

Please sign in to comment.