ImageTool: Prefer AllocateCopyPool()

This commit is contained in:
Marvin Häuser 2023-06-22 16:31:22 +02:00 committed by MikhailKrichanov
parent 329772c824
commit 6bae938f40

View File

@ -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;