diff options
author | eric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-02-02 08:01:35 +0000 |
---|---|---|
committer | eric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-02-02 08:01:35 +0000 |
commit | 57dfc48f933ce50c2d269e66eec7bab0c66938d6 (patch) | |
tree | be7768f37b902cb55698c868bdbb5b3d0e0c800a /MdeModulePkg/Core | |
parent | 0ea756d4033f9a6175dee4718e27e3c70b57dc9b (diff) | |
download | edk2-platforms-57dfc48f933ce50c2d269e66eec7bab0c66938d6.tar.xz |
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
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r-- | MdeModulePkg/Core/Dxe/Image/Image.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index 36893d9650..1ee65ae024 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -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"));
|