Revision: 19735
http://sourceforge.net/p/edk2/code/19735
Author: ydong10
Date: 2016-01-25 03:38:19 +0000 (Mon, 25 Jan 2016)
Log Message:
-----------
MdeModulePkg: HiiDatabase: Refine the code to make it more safely.
Refine the code to avoid potential buffer overflow or use NULL pointer.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Modified Paths:
--------------
trunk/edk2/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
Modified: trunk/edk2/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c 2016-01-25
03:33:45 UTC (rev 19734)
+++ trunk/edk2/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c 2016-01-25
03:38:19 UTC (rev 19735)
@@ -2,7 +2,7 @@
Implementation for EFI_HII_IMAGE_PROTOCOL.
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
which accompanies this distribution. The full text of the license may be
found at
@@ -266,7 +266,7 @@
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapPtr;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue[2];
EFI_HII_IMAGE_PALETTE_INFO *Palette;
- UINT16 PaletteSize;
+ UINTN PaletteSize;
UINT8 Byte;
ASSERT (Image != NULL && Data != NULL && PaletteInfo != NULL);
@@ -276,10 +276,14 @@
//
// First entry corresponds to color 0 and second entry corresponds to color
1.
//
+ PaletteSize = 0;
CopyMem (&PaletteSize, PaletteInfo, sizeof (UINT16));
PaletteSize += sizeof (UINT16);
Palette = AllocateZeroPool (PaletteSize);
ASSERT (Palette != NULL);
+ if (Palette == NULL) {
+ return;
+ }
CopyMem (Palette, PaletteInfo, PaletteSize);
ZeroMem (PaletteValue, sizeof (PaletteValue));
@@ -350,7 +354,7 @@
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapPtr;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue[16];
EFI_HII_IMAGE_PALETTE_INFO *Palette;
- UINT16 PaletteSize;
+ UINTN PaletteSize;
UINT16 PaletteNum;
UINT8 Byte;
@@ -361,10 +365,14 @@
//
// The bitmap should allocate each color index starting from 0.
//
+ PaletteSize = 0;
CopyMem (&PaletteSize, PaletteInfo, sizeof (UINT16));
PaletteSize += sizeof (UINT16);
Palette = AllocateZeroPool (PaletteSize);
ASSERT (Palette != NULL);
+ if (Palette == NULL) {
+ return;
+ }
CopyMem (Palette, PaletteInfo, PaletteSize);
PaletteNum = (UINT16)(Palette->PaletteSize / sizeof (EFI_HII_RGB_PIXEL));
@@ -424,7 +432,7 @@
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapPtr;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue[256];
EFI_HII_IMAGE_PALETTE_INFO *Palette;
- UINT16 PaletteSize;
+ UINTN PaletteSize;
UINT16 PaletteNum;
UINT8 Byte;
@@ -435,10 +443,14 @@
//
// The bitmap should allocate each color index starting from 0.
//
+ PaletteSize = 0;
CopyMem (&PaletteSize, PaletteInfo, sizeof (UINT16));
PaletteSize += sizeof (UINT16);
Palette = AllocateZeroPool (PaletteSize);
ASSERT (Palette != NULL);
+ if (Palette == NULL) {
+ return;
+ }
CopyMem (Palette, PaletteInfo, PaletteSize);
PaletteNum = (UINT16)(Palette->PaletteSize / sizeof (EFI_HII_RGB_PIXEL));
ZeroMem (PaletteValue, sizeof (PaletteValue));
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits