Bug 1247741 - Additional checks for pointer validity in LdrLoadDLL detour. r=aklotz

This commit is contained in:
Gian-Carlo Pascutto 2016-02-18 00:56:00 +01:00
parent b4c7567e87
commit d9a89388aa

View File

@ -486,7 +486,10 @@ getFullPath (PWCHAR filePath, wchar_t* fname)
// path name. For example, its numerical value can be 1. Passing a non-valid
// pointer to SearchPathW will cause a crash, so we need to check to see if we
// are handed a valid pointer, and otherwise just pass nullptr to SearchPathW.
PWCHAR sanitizedFilePath = (intptr_t(filePath) < 4096) ? nullptr : filePath;
PWCHAR sanitizedFilePath = nullptr;
if ((uintptr_t(filePath) >= 65536) && ((uintptr_t(filePath) & 1) == 0)) {
sanitizedFilePath = filePath;
}
// figure out the length of the string that we need
DWORD pathlen = SearchPathW(sanitizedFilePath, fname, L".dll", 0, nullptr,