]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Refine code to make it more safely.
authorEric Dong <eric.dong@intel.com>
Thu, 26 Jun 2014 03:16:27 +0000 (03:16 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 26 Jun 2014 03:16:27 +0000 (03:16 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15595 6f19259b-4bc3-4df7-8a09-765794883524

EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c
EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ValueToString.c
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c

index 5453c5a754cf4f4f3d43f4bc36e53d5deff6b1b1..386ff327f81bd3958ba3a412be9b2593be73daa0 100644 (file)
@@ -2,7 +2,7 @@
 Framework to UEFI 2.1 HII Thunk. The driver consume UEFI HII protocols\r
 to produce a Framework HII protocol.\r
 \r
-Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2008 - 2014, 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
@@ -158,6 +158,7 @@ InitializeHiiDatabase (
 \r
   Status = ListPackageLists (EFI_HII_PACKAGE_STRINGS, NULL, &BufferLength, &Buffer);\r
   if (Status == EFI_SUCCESS) {\r
+    ASSERT (Buffer != NULL);\r
     for (Index = 0; Index < BufferLength / sizeof (EFI_HII_HANDLE); Index++) {\r
       ThunkContext = CreateThunkContextForUefiHiiHandle (Buffer[Index]);\r
       ASSERT (ThunkContext!= NULL);\r
index 4c4411fabb9328d49deeab941517aa1874bf6cd1..07b99fbecb7dd3f08604bdf6f8a86d1b8d7710e7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Parser for IFR binary encoding.\r
 \r
-Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2008 - 2014, 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
@@ -1024,10 +1024,12 @@ ParseOpCodes (
 \r
       case EFI_IFR_FORM_OP:\r
       case EFI_IFR_FORM_MAP_OP:\r
+        ASSERT (CurrentForm != NULL);\r
         ImageId = &CurrentForm->ImageId;\r
         break;\r
 \r
       case EFI_IFR_ONE_OF_OPTION_OP:\r
+        ASSERT (CurrentOption != NULL);\r
         ImageId = &CurrentOption->ImageId;\r
         break;\r
 \r
index 8ab071fc458f5579d06a1fe27133ddae7d01a37d..6f62a178345f77ef46cb1dd0310b51c231ba59f3 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2014, 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
@@ -88,7 +88,7 @@ Returns:
     if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {\r
       if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {\r
         Status     = EFI_SUCCESS;\r
-        *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));\r
+        *Interface = (VOID *) *(UINTN *) (GuidHob.Guid + 1);\r
       }\r
     }\r
 \r
index 9d4260768c3f10569c94a25c641d9ff86e494457..da3904d238baa152464e52fbeb945431f19f9d8c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2014, 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
@@ -214,6 +214,8 @@ Arguments:
   UINTN         Rem;\r
   static CHAR16 *SizeUnits[] = { L" B", L" kB", L" MB", L" GB", L" TB", L" PB" };\r
 \r
+  Rem = 0;\r
+\r
   for (i = 0; i < (sizeof (SizeUnits) / sizeof (SizeUnits)[0]); i++) {\r
 \r
     DivU64x32 (Val, 1024, &Rem);\r
index 11f190145cba3f231aeb652d524fd8edfee9b1ee..7d79fb2e815556d83123d88da0a5c0e9f1158638 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2014, 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
@@ -155,6 +155,7 @@ Returns:
   Count           = 0;\r
   ValueCharNum    = 0;\r
   ValueIsNegative = FALSE;\r
+  Remainder       = 0;\r
 \r
   if (Width > CHARACTER_NUMBER_FOR_VALUE - 1) {\r
     Width = CHARACTER_NUMBER_FOR_VALUE - 1;\r
index b854cbe34e0a7750565e8177f42b6faadaa91070..55c0a043d4e300dca7f1782974794015ff878abc 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2014, 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
@@ -527,6 +527,7 @@ Returns:
   BufferPtr   = Buffer;\r
   Count       = 0;\r
   NumberCount = 0;\r
+  Remainder   = 0;\r
 \r
   if (Value < 0) {\r
     Negative = TRUE;\r
index 2b681224caca199049ac7fc6d3b3c9877970e9b1..727e6636b9be8c72875f99c7289efc807a7deed4 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2014, 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
@@ -114,7 +114,7 @@ Returns:
     if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {\r
       if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {\r
         Status     = EFI_SUCCESS;\r
-        *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));\r
+        *Interface = (VOID *) *(UINTN *) (GuidHob.Guid + 1);\r
       }\r
     }\r
 \r
index a796708fbc5fc2a76d2fbf00b9fbf854e4a1fcde..75e69784fa9de3e30e110c5312bd33e479e6081c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2014, 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
@@ -114,7 +114,7 @@ Returns:
     if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {\r
       if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {\r
         Status     = EFI_SUCCESS;\r
-        *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));\r
+        *Interface = (VOID *) *(UINTN *) (GuidHob.Guid + 1);\r
       }\r
     }\r
 \r