[edk2] [Patch 1/6] BaseTools/Split: Fix the segmentation fault in GetSplitValue()

Yonghong Zhu posted 6 patches 7 years, 5 months ago
[edk2] [Patch 1/6] BaseTools/Split: Fix the segmentation fault in GetSplitValue()
Posted by Yonghong Zhu 7 years, 5 months ago
Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=538
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/C/Split/Split.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/Split/Split.c b/BaseTools/Source/C/Split/Split.c
index 7ab66be..6b0a323 100644
--- a/BaseTools/Source/C/Split/Split.c
+++ b/BaseTools/Source/C/Split/Split.c
@@ -1,10 +1,10 @@
 /** @file
 
   Split a file into two pieces at the request offset.
 
-Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 1999 - 2017, 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
 http://opensource.org/licenses/bsd-license.php
 
@@ -78,11 +78,11 @@ Returns:
   GC_TODO: add return values
 
 --*/
 {
   Version();
-  printf ("Copyright (c) 1999-2016 Intel Corporation. All rights reserved.\n");
+  printf ("Copyright (c) 1999-2017 Intel Corporation. All rights reserved.\n");
   printf ("\n  SplitFile creates two Binary files either in the same directory as the current working\n");
   printf ("  directory or in the specified directory.\n");
   printf ("\nUsage: \n\
    Split\n\
      -f, --filename inputFile to split\n\
@@ -101,17 +101,21 @@ EFI_STATUS
 GetSplitValue (
   IN CONST CHAR8* SplitValueString,
   OUT UINT64 *ReturnValue
 )
 {
-  UINT64 len = strlen(SplitValueString);
+  UINT64 len = 0;
   UINT64 base = 1;
   UINT64 index = 0;
   UINT64 number = 0;
   CHAR8 lastCHAR = 0;
   EFI_STATUS Status = EFI_SUCCESS;
 
+  if (SplitValueString != NULL){
+    len = strlen(SplitValueString);
+  }
+
   if (len == 0) {
     return EFI_ABORTED;
   }
 
   Status = AsciiStringToUint64 (SplitValueString, FALSE, ReturnValue);
-- 
2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel