]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IScsiDxe/IScsiCHAP.c
ArmPkg/GenericWatchdogDxe: clean up the code
[mirror_edk2.git] / NetworkPkg / IScsiDxe / IScsiCHAP.c
index 4cfbba7b5cdba32d9774876413f6a0e9e62aff8f..da6da3f17ed9fc0e142cf51fe5279200c0d7cacf 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This file is for Challenge-Handshake Authentication Protocol (CHAP) Configuration.\r
 \r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2018, 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
@@ -15,16 +15,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "IScsiImpl.h"\r
 \r
 /**\r
-  Initator caculates its own expected hash value.\r
-  \r
+  Initator calculates its own expected hash value.\r
+\r
   @param[in]   ChapIdentifier     iSCSI CHAP identifier sent by authenticator.\r
   @param[in]   ChapSecret         iSCSI CHAP secret of the authenticator.\r
   @param[in]   SecretLength       The length of iSCSI CHAP secret.\r
   @param[in]   ChapChallenge      The challenge message sent by authenticator.\r
   @param[in]   ChallengeLength    The length of iSCSI CHAP challenge message.\r
   @param[out]  ChapResponse       The calculation of the expected hash value.\r
-  \r
-  @retval EFI_SUCCESS             The expected hash value was caculatedly successfully.\r
+\r
+  @retval EFI_SUCCESS             The expected hash value was calculatedly successfully.\r
   @retval EFI_PROTOCOL_ERROR      The length of the secret should be at least the\r
                                   length of the hash value for the hashing algorithm chosen.\r
   @retval EFI_PROTOCOL_ERROR      MD5 hash operation fail.\r
@@ -95,10 +95,10 @@ Exit:
 \r
 /**\r
   The initator checks the CHAP response replied by target against its own\r
-  calculation of the expected hash value. \r
-  \r
-  @param[in]   AuthData             iSCSI CHAP authentication data. \r
-  @param[in]   TargetResponse       The response from target.    \r
+  calculation of the expected hash value.\r
+\r
+  @param[in]   AuthData             iSCSI CHAP authentication data.\r
+  @param[in]   TargetResponse       The response from target.\r
 \r
   @retval EFI_SUCCESS               The response from target passed authentication.\r
   @retval EFI_SECURITY_VIOLATION    The response from target was not expected value.\r
@@ -267,12 +267,12 @@ IScsiCHAPOnRspReceived (
     //\r
     // Process the CHAP identifier and CHAP Challenge from Target.\r
     // Calculate Response value.\r
-    //    \r
+    //\r
     Result = IScsiNetNtoi (Identifier);\r
     if (Result > 0xFF) {\r
       goto ON_EXIT;\r
-    }    \r
-    \r
+    }\r
+\r
     AuthData->InIdentifier      = (UINT32) Result;\r
     AuthData->InChallengeLength = ISCSI_CHAP_AUTH_MAX_LEN;\r
     IScsiHexToBin ((UINT8 *) AuthData->InChallenge, &AuthData->InChallengeLength, Challenge);\r
@@ -331,7 +331,7 @@ ON_EXIT:
 \r
   if (KeyValueList != NULL) {\r
     IScsiFreeKeyValueList (KeyValueList);\r
-  }  \r
+  }\r
 \r
   FreePool (Data);\r
 \r
@@ -374,6 +374,9 @@ IScsiCHAPToSendReq (
   Session     = Conn->Session;\r
   AuthData    = &Session->AuthData.CHAP;\r
   LoginReq    = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, 0);\r
+  if (LoginReq == NULL) {\r
+    return EFI_PROTOCOL_ERROR;\r
+  }\r
   Status      = EFI_SUCCESS;\r
 \r
   RspLen      = 2 * ISCSI_CHAP_RSP_LEN + 3;\r