X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FC%2FGenSec%2FGenSec.c;h=c0e4de254b9809972a9e422ed495cd4fc6d4bc10;hb=79777358cd5dbdbb267ebd02405584321292f06a;hp=87d4fa88b92dd61937a91bfb85cebf1a4e5276c8;hpb=77e4cf5f11ed4543cbd91a9c45c7209e36bfd97a;p=mirror_edk2.git diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c index 87d4fa88b9..c0e4de254b 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -1,7 +1,7 @@ /** @file Creates output file that is a properly formed section per the PI spec. -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
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 @@ -146,7 +146,7 @@ Returns: // // Copyright declaration // - fprintf (stdout, "Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.\n\n"); + fprintf (stdout, "Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.\n\n"); // // Details Option @@ -897,16 +897,22 @@ Returns: return Status; } - if (FileBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - if (InputLength == 0) { - free (FileBuffer); + if (FileBuffer != NULL) { + free (FileBuffer); + } Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s can't be zero", InputFileName); return EFI_NOT_FOUND; } + // + // InputLength != 0, but FileBuffer == NULL means out of resources. + // + if (FileBuffer == NULL) { + Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated"); + return EFI_OUT_OF_RESOURCES; + } + // // Now data is in FileBuffer + Offset // @@ -1114,6 +1120,10 @@ Returns: } if ((stricmp (argv[0], "-r") == 0) || (stricmp (argv[0], "--attributes") == 0)) { + if (argv[1] == NULL) { + Error (NULL, 0, 1003, "Invalid option value", "Guid section attributes can't be NULL"); + goto Finish; + } if (stricmp (argv[1], mGUIDedSectionAttribue[EFI_GUIDED_SECTION_PROCESSING_REQUIRED]) == 0) { SectGuidAttribute |= EFI_GUIDED_SECTION_PROCESSING_REQUIRED; } else if (stricmp (argv[1], mGUIDedSectionAttribue[EFI_GUIDED_SECTION_AUTH_STATUS_VALID]) == 0) {