From d9a89388aadb5b0b3e3215f8fc58249def0c2c65 Mon Sep 17 00:00:00 2001 From: Gian-Carlo Pascutto Date: Thu, 18 Feb 2016 00:56:00 +0100 Subject: [PATCH] Bug 1247741 - Additional checks for pointer validity in LdrLoadDLL detour. r=aklotz --- mozglue/build/WindowsDllBlocklist.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mozglue/build/WindowsDllBlocklist.cpp b/mozglue/build/WindowsDllBlocklist.cpp index a3fa9c48991..670330942ff 100644 --- a/mozglue/build/WindowsDllBlocklist.cpp +++ b/mozglue/build/WindowsDllBlocklist.cpp @@ -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,