]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Fix unspecified address use case in IpsecConfig
authorJiaxin Wu <jiaxin.wu@intel.com>
Wed, 15 Jun 2016 08:23:51 +0000 (16:23 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Fri, 17 Jun 2016 02:52:40 +0000 (10:52 +0800)
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>
NetworkPkg/Application/IpsecConfig/Indexer.c
NetworkPkg/Application/IpsecConfig/Indexer.h
NetworkPkg/Application/IpsecConfig/Match.c

index 83ceda4b57f04043889c1da9965b19d0d3bc9c80..353b22e06a8777118b35d9b9b8c622ead8b41060 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of construct ENTRY_INDEXER in IpSecConfig application.\r
 \r
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -44,17 +44,19 @@ ConstructSpdIndexer (
   } else if (ShellCommandLineGetFlag (ParamPackage, L"-e")) {\r
     ValueStr = ShellCommandLineGetValue (ParamPackage, L"-e");\r
   } else {\r
-    ASSERT (FALSE);\r
+    return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  ASSERT (ValueStr != NULL);\r
-\r
+  if (ValueStr == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
   Value64 = StrToUInteger (ValueStr, &Status);\r
   if (!EFI_ERROR (Status)) {\r
     Indexer->Index = (UINTN) Value64;\r
-    Indexer->Name  = NULL;\r
+    ZeroMem (Indexer->Name, MAX_PEERID_LEN);\r
   } else {\r
-    UnicodeStrToAsciiStr (ValueStr, (CHAR8 *) Indexer->Name);\r
+    UnicodeStrToAsciiStrS (ValueStr, (CHAR8 *) Indexer->Name, MAX_PEERID_LEN);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -89,10 +91,12 @@ ConstructSadIndexer (
   } else if (ShellCommandLineGetFlag (ParamPackage, L"-e")) {\r
     ValueStr = ShellCommandLineGetValue (ParamPackage, L"-e");\r
   } else {\r
-    ASSERT (FALSE);\r
+    return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  ASSERT (ValueStr != NULL);\r
+  if (ValueStr == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
 \r
   Value64 = StrToUInteger (ValueStr, &Status);\r
   if (!EFI_ERROR (Status)) {\r
@@ -187,10 +191,12 @@ ConstructPadIndexer (
   } else if (ShellCommandLineGetFlag (ParamPackage, L"-e")) {\r
     ValueStr = ShellCommandLineGetValue (ParamPackage, L"-e");\r
   } else {\r
-    ASSERT (FALSE);\r
+    return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  ASSERT (ValueStr != NULL);\r
+  if (ValueStr == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
 \r
   Value64 = StrToUInteger (ValueStr, &Status);\r
 \r
index 078f38a3127948220e60792ea03207c34ead3570..58c0689021a13c6648be99675ea47484af406bb6 100644 (file)
@@ -2,7 +2,7 @@
   The internal structure and function declaration to construct ENTRY_INDEXER in\r
   IpSecConfig application.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -18,8 +18,8 @@
 #define _INDEXER_H_\r
 \r
 typedef struct {\r
-  UINT8    *Name;\r
-  UINTN    Index;    // Used only if Name is NULL.\r
+  UINT8    Name[MAX_PEERID_LEN];\r
+  UINTN    Index;    // Used only if Name buffer is filled with zero.\r
 } SPD_ENTRY_INDEXER;\r
 \r
 typedef struct {\r
index d283f5b7168e8cfc0a96326b5471b20be9604ede..2ee763e60748bc0bd346108985a64b7537bd2ee6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of match policy entry function in IpSecConfig application.\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -63,7 +63,7 @@ MatchSpdEntry (
   BOOLEAN    Match;\r
 \r
   Match = FALSE;\r
-  if (Indexer->Name != NULL) {\r
+  if (!IsMemoryZero (Indexer->Name, MAX_PEERID_LEN)) {\r
     if ((Data->Name != NULL) && (AsciiStrCmp ((CHAR8 *) Indexer->Name, (CHAR8 *) Data->Name) == 0)) {\r
       Match = TRUE;\r
     }\r