Fix code potential errors in IPsec.

Signed-off-by: qianouyang
Reviewed-by:  ydong10



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13856 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qianouyang 2012-10-17 05:46:53 +00:00
parent 616ac6f569
commit 1a6fdcb009
2 changed files with 9 additions and 7 deletions

View File

@ -19,7 +19,7 @@
// //
// The print title for IKEv1 variety phase. // The print title for IKEv1 variety phase.
// //
CHAR8 *mIkev1StateStr[] = { CHAR8 *mIkev1StateStr[IKE_STATE_NUM] = {
"IKEv1_MAIN_1", "IKEv1_MAIN_1",
"IKEv1_MAIN_2", "IKEv1_MAIN_2",
"IKEv1_MAIN_3", "IKEv1_MAIN_3",
@ -32,7 +32,7 @@ CHAR8 *mIkev1StateStr[] = {
// //
// The print title for IKEv2 variety phase. // The print title for IKEv2 variety phase.
// //
CHAR8 *mIkev2StateStr[] = { CHAR8 *mIkev2StateStr[IKE_STATE_NUM] = {
"IKEv2_STATE_INIT", "IKEv2_STATE_INIT",
"IKEv2_STATE_AUTH", "IKEv2_STATE_AUTH",
"IKEv2_STATE_SA_ESTABLISH", "IKEv2_STATE_SA_ESTABLISH",
@ -166,6 +166,9 @@ IkeDumpState (
IN UINT8 IkeVersion IN UINT8 IkeVersion
) )
{ {
if (Previous >= IKE_STATE_NUM || Current >= IKE_STATE_NUM) {
return;
}
if (Previous == Current) { if (Previous == Current) {
if (IkeVersion == 1) { if (IkeVersion == 1) {
@ -173,16 +176,13 @@ IkeDumpState (
} else if (IkeVersion == 2) { } else if (IkeVersion == 2) {
DEBUG ((DEBUG_INFO, "\n****Current state is %a\n", mIkev2StateStr[Previous])); DEBUG ((DEBUG_INFO, "\n****Current state is %a\n", mIkev2StateStr[Previous]));
} }
} else { } else {
if (IkeVersion == 1) { if (IkeVersion == 1) {
DEBUG ((DEBUG_INFO, "\n****Change state from %a to %a\n", mIkev1StateStr[Previous], mIkev1StateStr[Current])); DEBUG ((DEBUG_INFO, "\n****Change state from %a to %a\n", mIkev1StateStr[Previous], mIkev1StateStr[Current]));
} else { } else {
DEBUG ((DEBUG_INFO, "\n****Change state from %a to %a\n", mIkev2StateStr[Previous], mIkev2StateStr[Current])); DEBUG ((DEBUG_INFO, "\n****Change state from %a to %a\n", mIkev2StateStr[Previous], mIkev2StateStr[Current]));
} }
} }
} }
/** /**

View File

@ -27,6 +27,8 @@
#define IPSEC_DUMP_BUF(Title, Data, DataSize) IpSecDumpBuf (Title, Data, DataSize) #define IPSEC_DUMP_BUF(Title, Data, DataSize) IpSecDumpBuf (Title, Data, DataSize)
#define IPSEC_DEBUG_BYTE_PER_LINE 8 #define IPSEC_DEBUG_BYTE_PER_LINE 8
#define IKE_STATE_NUM 7
/** /**