From 6bae938f4086bd5f393a0d1fe6ff70ce555f9b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Ha=CC=88user?= <8659494+mhaeuser@users.noreply.github.com> Date: Thu, 22 Jun 2023 16:31:22 +0200 Subject: [PATCH] ImageTool: Prefer AllocateCopyPool() --- BaseTools/ImageTool/PeScan.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BaseTools/ImageTool/PeScan.c b/BaseTools/ImageTool/PeScan.c index b0dfc53d51..42aff03009 100644 --- a/BaseTools/ImageTool/PeScan.c +++ b/BaseTools/ImageTool/PeScan.c @@ -202,14 +202,15 @@ ScanPeGetSegmentInfo ( && memcmp (Section->Name, PE_COFF_SECT_NAME_RELOC, sizeof (Section->Name)) != 0 && memcmp (Section->Name, PE_COFF_SECT_NAME_RESRC, sizeof (Section->Name)) != 0 && memcmp (Section->Name, PE_COFF_SECT_NAME_DEBUG, sizeof (Section->Name)) != 0) { - ImageSegment->Name = AllocateZeroPool (sizeof (Section->Name)); + ImageSegment->Name = AllocateCopyPool ( + sizeof (Section->Name), + Section->Name + ); if (ImageSegment->Name == NULL) { fprintf (stderr, "ImageTool: Could not allocate memory for Segment Name\n"); return RETURN_OUT_OF_RESOURCES; } - memmove (ImageSegment->Name, Section->Name, sizeof (Section->Name)); - ImageSegment->ImageAddress = Section->VirtualAddress; ImageSegment->ImageSize = ALIGN_VALUE (Section->VirtualSize, SegmentInfo->SegmentAlignment); ImageSegment->Read = (Section->Characteristics & EFI_IMAGE_SCN_MEM_READ) != 0;