Sathya Prakash [mailto:[email protected]] wrote:
]I would like to see the CopyMem implementation. Which source
]file I should look for it. I see some implementation in
]commonlib.c in basetools but I assume it wont be taken from
]there and instead will be used from boot services table. So
]how can I know about the implementation. The reason I want
]to look into that is, in reallocatepool, there is a
]possibility that the CopyMem can be called with 0 length.
]If CopyMem implementation is similar to what is in commonlib.c
](as mentioned below), the 0 will be decremented and due to the
]type of length (UINTN) there might be some memory corruption.
]
]Please correct if my understanding is wrong.
A reliable way to find which CopyMem source code is used by
ReallocatePool is to step into the CopyMem call using a source
level debugger.
If the code below is called with Length zero, no data will be
copied. This is because the while loop uses a postfix decrement
of Length as opposed to a prefix decrement of Length.
Your question to Andrew about the return value of the function
below does point out an inconsistency between the BaseTools
CopyMem and the other CopyMem implementations. But this
inconsistency seems more of an annoyance than a danger. This
is because the function prototype of the BaseTools version will
prevent the compile of any code that tries to use its return
value.
A bigger danger of the BaseTools CopyMem code below is that
it does not support copy of overlapping buffers as do the
other CopyMem implementations. The compiler cannot flag
cases where BaseTools code calls CopyMem with overlapping
buffers.
Thanks,
Scott
]VOID
]PeiCopyMem (
] IN VOID *Destination,
] IN VOID *Source,
] IN UINTN Length
] )
]/*++
]
]Routine Description:
]
] Copy Length bytes from Source to Destination.
]
]Arguments:
]
] Destination - Target of copy
]
] Source - Place to copy from
]
] Length - Number of bytes to copy
]
]Returns:
]
] None
]
]--*/
]{
] CHAR8 *Destination8;
] CHAR8 *Source8;
]
] Destination8 = Destination;
] Source8 = Source;
] while (Length--) {
] *(Destination8++) = *(Source8++);
] }
]}
]
]Thanks
]Sathya
]
]PS: My E-mail ID changed from [email protected] to
][email protected]. Please update your address book.
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel