summaryrefslogtreecommitdiff
path: root/NetworkPkg/Application/IpsecConfig
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2016-06-15 16:23:51 +0800
committerJiaxin Wu <jiaxin.wu@intel.com>2016-06-17 10:52:40 +0800
commitca9b4d22f437ccd2d7ad9ce262760097788bafcc (patch)
tree64c0850d3919bc7662eaacc677c92799a4d92fa5 /NetworkPkg/Application/IpsecConfig
parentd8d217c57632549d99256f134a4cee6be8dc67bb (diff)
downloadedk2-platforms-ca9b4d22f437ccd2d7ad9ce262760097788bafcc.tar.xz
NetworkPkg: Fix unspecified address use case in IpsecConfig
This patch is used to fix unspecified address use case in ConstructSpdIndexer() function. Indexer->Name for ConstructSpdIndexer is unspecified, that will be a problem for UnicodeStrToAsciiStr. This patch also refine the code by removing ASSERT and user error handling. Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Ye Ting <ting.ye@intel.com> Cc: Zeng Star <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Zeng Star <star.zeng@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Diffstat (limited to 'NetworkPkg/Application/IpsecConfig')
-rw-r--r--NetworkPkg/Application/IpsecConfig/Indexer.c26
-rw-r--r--NetworkPkg/Application/IpsecConfig/Indexer.h6
-rw-r--r--NetworkPkg/Application/IpsecConfig/Match.c4
3 files changed, 21 insertions, 15 deletions
diff --git a/NetworkPkg/Application/IpsecConfig/Indexer.c b/NetworkPkg/Application/IpsecConfig/Indexer.c
index 83ceda4b57..353b22e06a 100644
--- a/NetworkPkg/Application/IpsecConfig/Indexer.c
+++ b/NetworkPkg/Application/IpsecConfig/Indexer.c
@@ -1,7 +1,7 @@
/** @file
The implementation of construct ENTRY_INDEXER in IpSecConfig application.
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2016, 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
@@ -44,17 +44,19 @@ ConstructSpdIndexer (
} else if (ShellCommandLineGetFlag (ParamPackage, L"-e")) {
ValueStr = ShellCommandLineGetValue (ParamPackage, L"-e");
} else {
- ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
}
- ASSERT (ValueStr != NULL);
-
+ if (ValueStr == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
Value64 = StrToUInteger (ValueStr, &Status);
if (!EFI_ERROR (Status)) {
Indexer->Index = (UINTN) Value64;
- Indexer->Name = NULL;
+ ZeroMem (Indexer->Name, MAX_PEERID_LEN);
} else {
- UnicodeStrToAsciiStr (ValueStr, (CHAR8 *) Indexer->Name);
+ UnicodeStrToAsciiStrS (ValueStr, (CHAR8 *) Indexer->Name, MAX_PEERID_LEN);
}
return EFI_SUCCESS;
@@ -89,10 +91,12 @@ ConstructSadIndexer (
} else if (ShellCommandLineGetFlag (ParamPackage, L"-e")) {
ValueStr = ShellCommandLineGetValue (ParamPackage, L"-e");
} else {
- ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
}
- ASSERT (ValueStr != NULL);
+ if (ValueStr == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
Value64 = StrToUInteger (ValueStr, &Status);
if (!EFI_ERROR (Status)) {
@@ -187,10 +191,12 @@ ConstructPadIndexer (
} else if (ShellCommandLineGetFlag (ParamPackage, L"-e")) {
ValueStr = ShellCommandLineGetValue (ParamPackage, L"-e");
} else {
- ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
}
- ASSERT (ValueStr != NULL);
+ if (ValueStr == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
Value64 = StrToUInteger (ValueStr, &Status);
diff --git a/NetworkPkg/Application/IpsecConfig/Indexer.h b/NetworkPkg/Application/IpsecConfig/Indexer.h
index 078f38a312..58c0689021 100644
--- a/NetworkPkg/Application/IpsecConfig/Indexer.h
+++ b/NetworkPkg/Application/IpsecConfig/Indexer.h
@@ -2,7 +2,7 @@
The internal structure and function declaration to construct ENTRY_INDEXER in
IpSecConfig application.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2016, 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
@@ -18,8 +18,8 @@
#define _INDEXER_H_
typedef struct {
- UINT8 *Name;
- UINTN Index; // Used only if Name is NULL.
+ UINT8 Name[MAX_PEERID_LEN];
+ UINTN Index; // Used only if Name buffer is filled with zero.
} SPD_ENTRY_INDEXER;
typedef struct {
diff --git a/NetworkPkg/Application/IpsecConfig/Match.c b/NetworkPkg/Application/IpsecConfig/Match.c
index d283f5b716..2ee763e607 100644
--- a/NetworkPkg/Application/IpsecConfig/Match.c
+++ b/NetworkPkg/Application/IpsecConfig/Match.c
@@ -1,7 +1,7 @@
/** @file
The implementation of match policy entry function in IpSecConfig application.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2016, 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
@@ -63,7 +63,7 @@ MatchSpdEntry (
BOOLEAN Match;
Match = FALSE;
- if (Indexer->Name != NULL) {
+ if (!IsMemoryZero (Indexer->Name, MAX_PEERID_LEN)) {
if ((Data->Name != NULL) && (AsciiStrCmp ((CHAR8 *) Indexer->Name, (CHAR8 *) Data->Name) == 0)) {
Match = TRUE;
}