From: Hao Wu Date: Tue, 30 Aug 2016 01:59:02 +0000 (+0800) Subject: SecurityPkg: Use IsZeroGuid API for zero GUID checking X-Git-Tag: edk2-stable201903~5924 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=965268ea6df485d78b982d00270bd4ce7f673820;hp=39cde03cc5efd67c11dc75cd5ba5e8ccf55c5594 SecurityPkg: Use IsZeroGuid API for zero GUID checking Instead of comparing a GUID with gZeroGuid via the CompareGuid API, the commit uses the IsZeroGuid API to check if the given GUID is a zero GUID. Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Chao Zhang --- diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c index 1f2574e93e..aacafa83b3 100644 --- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c +++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c @@ -15,7 +15,7 @@ Tcg2MeasureGptTable() function will receive untrusted GPT partition table, and parse partition data carefully. -Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -36,7 +36,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include -#include #include #include @@ -202,7 +201,7 @@ Tcg2MeasureGptTable ( PartitionEntry = (EFI_PARTITION_ENTRY *)EntryPtr; NumberOfPartition = 0; for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) { - if (!CompareGuid (&PartitionEntry->PartitionTypeGUID, &gZeroGuid)) { + if (!IsZeroGuid (&PartitionEntry->PartitionTypeGUID)) { NumberOfPartition++; } PartitionEntry = (EFI_PARTITION_ENTRY *)((UINT8 *)PartitionEntry + PrimaryHeader->SizeOfPartitionEntry); @@ -238,7 +237,7 @@ Tcg2MeasureGptTable ( PartitionEntry = (EFI_PARTITION_ENTRY*)EntryPtr; NumberOfPartition = 0; for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) { - if (!CompareGuid (&PartitionEntry->PartitionTypeGUID, &gZeroGuid)) { + if (!IsZeroGuid (&PartitionEntry->PartitionTypeGUID)) { CopyMem ( (UINT8 *)&GptData->Partitions + NumberOfPartition * PrimaryHeader->SizeOfPartitionEntry, (UINT8 *)PartitionEntry, diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf index 1296c977b4..a11988e4aa 100644 --- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf +++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf @@ -9,7 +9,7 @@ # This external input must be validated carefully to avoid security issues such # as buffer overflow or integer overflow. # -# Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2013 - 2016, 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 @@ -58,7 +58,6 @@ [Guids] gMeasuredFvHobGuid ## SOMETIMES_CONSUMES ## HOB - gZeroGuid ## SOMETIMES_CONSUMES ## GUID [Protocols] gEfiTcg2ProtocolGuid ## SOMETIMES_CONSUMES diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c index 8ab60d871d..52bf582d82 100644 --- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c +++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c @@ -34,7 +34,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include -#include #include #include @@ -202,7 +201,7 @@ TcgMeasureGptTable ( PartitionEntry = (EFI_PARTITION_ENTRY *)EntryPtr; NumberOfPartition = 0; for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) { - if (!CompareGuid (&PartitionEntry->PartitionTypeGUID, &gZeroGuid)) { + if (!IsZeroGuid (&PartitionEntry->PartitionTypeGUID)) { NumberOfPartition++; } PartitionEntry = (EFI_PARTITION_ENTRY *)((UINT8 *)PartitionEntry + PrimaryHeader->SizeOfPartitionEntry); @@ -236,7 +235,7 @@ TcgMeasureGptTable ( PartitionEntry = (EFI_PARTITION_ENTRY*)EntryPtr; NumberOfPartition = 0; for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) { - if (!CompareGuid (&PartitionEntry->PartitionTypeGUID, &gZeroGuid)) { + if (!IsZeroGuid (&PartitionEntry->PartitionTypeGUID)) { CopyMem ( (UINT8 *)&GptData->Partitions + NumberOfPartition * PrimaryHeader->SizeOfPartitionEntry, (UINT8 *)PartitionEntry, diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf index 0d58eec9b5..553e68321e 100644 --- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf +++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf @@ -9,7 +9,7 @@ # This external input must be validated carefully to avoid security issues such # as buffer overflow or integer overflow. # -# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2016, 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 @@ -58,7 +58,6 @@ [Guids] gMeasuredFvHobGuid ## SOMETIMES_CONSUMES ## HOB - gZeroGuid ## SOMETIMES_CONSUMES ## GUID [Protocols] gEfiTcgProtocolGuid ## SOMETIMES_CONSUMES