Permalink
Browse files

ELF loading potential out-of-bounds fix

  • Loading branch information...
hrydgard committed Jun 6, 2017
1 parent b1b3b7c commit 42bdf3e19b31a27f5855122b4a4b020a2aac568e
Showing with 4 additions and 4 deletions.
  1. +2 −2 Core/ELF/ElfReader.cpp
  2. +2 −2 Core/HLE/sceKernelModule.cpp
View
@@ -29,8 +29,8 @@ const char *ElfReader::GetSectionName(int section) const {
return nullptr;
int nameOffset = sections[section].sh_name;
if (nameOffset < 0) { // TODO: Where can we get a solid upper limit?
ERROR_LOG(LOADER, "ELF: Bad name offset %d in section %d", nameOffset, section);
if (nameOffset < 0 || nameOffset >= size_) {
ERROR_LOG(LOADER, "ELF: Bad name offset %d in section %d (max = %d)", nameOffset, section, (int)size_);
return nullptr;
}
const char *ptr = (const char *)GetSectionDataPtr(header->e_shstrndx);
@@ -1153,7 +1153,7 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd
module->Cleanup();
kernelObjects.Destroy<Module>(module->GetUID());
error = SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE;
return 0;
return nullptr;
}
// Open ELF reader
@@ -1167,7 +1167,7 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd
module->Cleanup();
kernelObjects.Destroy<Module>(module->GetUID());
error = result;
return 0;
return nullptr;
}
module->memoryBlockAddr = reader.GetVaddr();
module->memoryBlockSize = reader.GetTotalSize();

0 comments on commit 42bdf3e

Please sign in to comment.