enhance the condition branch to handle Unix style file path. and avoid array overflow

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7394 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
eric_tian 2009-02-02 08:01:35 +00:00
parent 0ea756d403
commit 57dfc48f93
1 changed files with 10 additions and 3 deletions

View File

@ -477,19 +477,22 @@ CoreLoadPeImage (
//
// Print Module Name by Pdb file path
// Print Module Name by Pdb file path.
// Windows and Unix style file path are all trimmed correctly.
//
if (Image->ImageContext.PdbPointer != NULL) {
StartIndex = 0;
for (Index = 0; Image->ImageContext.PdbPointer[Index] != 0; Index++) {
if (Image->ImageContext.PdbPointer[Index] == '\\') {
if ((Image->ImageContext.PdbPointer[Index] == '\\') || (Image->ImageContext.PdbPointer[Index] == '/')) {
StartIndex = Index + 1;
}
}
//
// Copy the PDB file name to our temporary string, and replace .pdb with .efi
// The PDB file name is limited in the range of 0~255.
// If the length is bigger than 255, trim the redudant characters to avoid overflow in array boundary.
//
for (Index = 0; Index < sizeof (EfiFileName); Index++) {
for (Index = 0; Index < sizeof (EfiFileName) - 4; Index++) {
EfiFileName[Index] = Image->ImageContext.PdbPointer[Index + StartIndex];
if (EfiFileName[Index] == 0) {
EfiFileName[Index] = '.';
@ -502,6 +505,10 @@ CoreLoadPeImage (
break;
}
}
if (Index == sizeof (EfiFileName) - 4) {
EfiFileName[Index] = 0;
}
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName)); // &Image->ImageContext.PdbPointer[StartIndex]));
}
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n"));