]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/C/Common: Add checks for array access
authorHao Wu <hao.a.wu@intel.com>
Tue, 27 Sep 2016 05:28:33 +0000 (13:28 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 8 Nov 2016 08:37:01 +0000 (16:37 +0800)
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/C/Common/CommonLib.c
BaseTools/Source/C/Common/Decompress.c

index 2d07dfc667b19b3c9fc3c7cef7af1b713ff6b6c4..2f0aecf252409778090e33127ce482a5d2de80c5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Common basic Library Functions\r
 \r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, 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
@@ -652,7 +652,11 @@ Returns:
     //\r
     // Construct the full file path\r
     //\r
-    strcat (mCommonLibFullPath, FileName);\r
+    if (strlen (mCommonLibFullPath) + strlen (FileName) > MAX_LONG_FILE_PATH - 1) {\r
+      Error (NULL, 0, 2000, "Invalid parameter", "FileName %s is too long!", FileName);\r
+      return NULL;\r
+    }\r
+    strncat (mCommonLibFullPath, FileName, MAX_LONG_FILE_PATH - strlen (mCommonLibFullPath) - 1);\r
     \r
     //\r
     // Convert directory separator '/' to '\\'\r
index d266b6f90cae2b815f88df861145f2501320b91e..77df89ff48cba2a3756578ac7080037d6b927ed0 100644 (file)
@@ -2,7 +2,7 @@
 Decompressor. Algorithm Ported from OPSD code (Decomp.asm) for Efi and Tiano \r
 compress algorithm.\r
 \r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, 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
@@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <stdlib.h>\r
 #include <string.h>\r
+#include <assert.h>\r
 #include "Decompress.h"\r
 \r
 //\r
@@ -240,7 +241,7 @@ Returns:
   for (Char = 0; Char < NumOfChar; Char++) {\r
 \r
     Len = BitLen[Char];\r
-    if (Len == 0) {\r
+    if (Len == 0 || Len >= 17) {\r
       continue;\r
     }\r
 \r
@@ -373,6 +374,8 @@ Returns:
   UINT16  Index;\r
   UINT32  Mask;\r
 \r
+  assert (nn <= NPT);\r
+\r
   Number = (UINT16) GetBits (Sd, nbit);\r
 \r
   if (Number == 0) {\r