Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect return value type used for Wow64EnableWow64FsRedirection #4681

Closed
wixbot opened this issue Feb 20, 2015 · 5 comments
Closed

Incorrect return value type used for Wow64EnableWow64FsRedirection #4681

wixbot opened this issue Feb 20, 2015 · 5 comments
Assignees
Milestone

Comments

@wixbot
Copy link

wixbot commented Feb 20, 2015

src/libs/dutil/xmlutil.cpp: pfnEnableWow64 = (BOOL (WINAPI *)(BOOLEAN))::GetProcAddress(hKernel32, "Wow64EnableWow64FsRedirection");

The Wow64EnableWow64FsRedirection function (called by XmlCreateDocument) is declared as returning BOOL (32 bit). However it actually returns BOOLEAN (8 bit).
This means the upper 24 bits may be filled with garbage, which can lead to interpreting a return value of FALSE as TRUE. The effect of this would be termination without any error message (via ::ExitProcess(1); in the same function).

Most of the time this error will not be noticeable in practice because due to the implementation details of this function the "garbage" is determined by the last error value. The most common error code is ERROR_CALL_NOT_IMPLEMENTED (on 32-bit versions of Windows) with a value of 120, so the upper 24 bits happen to be zero; a rarer error code above 255 would exhibit this problem however.

Originally opened by thfabba

@wixbot
Copy link
Author

wixbot commented Feb 20, 2015

Fix:

diff --git a/src/libs/dutil/xmlutil.cpp b/src/libs/dutil/xmlutil.cpp
index d5e9c13..67a072d 100644
--- a/src/libs/dutil/xmlutil.cpp
+++ b/src/libs/dutil/xmlutil.cpp
@@ -130,7 +130,7 @@ extern "C" HRESULT DAPI XmlCreateDocument(
 {
     HRESULT hr = S_OK;
     BOOL (WINAPI *pfnDisableWow64)(__out PVOID* ) = NULL;
-    BOOL (WINAPI *pfnEnableWow64)(__in BOOLEAN ) = NULL;
+    BOOLEAN (WINAPI *pfnEnableWow64)(__in BOOLEAN ) = NULL;
     BOOL (WINAPI *pfnRevertWow64)(__in PVOID ) = NULL;
     BOOL fWow64Available = FALSE;
     void *pvWow64State = NULL;
@@ -147,7 +147,7 @@ extern "C" HRESULT DAPI XmlCreateDocument(
     if (NULL != GetProcAddress(hKernel32, "IsWow64Process"))
     {
         pfnDisableWow64 = (BOOL (WINAPI *)(PVOID *))::GetProcAddress(hKernel32, "Wow64DisableWow64FsRedirection");
-        pfnEnableWow64 = (BOOL (WINAPI *)(BOOLEAN))::GetProcAddress(hKernel32, "Wow64EnableWow64FsRedirection");
+        pfnEnableWow64 = (BOOLEAN (WINAPI *)(BOOLEAN))::GetProcAddress(hKernel32, "Wow64EnableWow64FsRedirection");
         pfnRevertWow64 = (BOOL (WINAPI *)(PVOID))::GetProcAddress(hKernel32, "Wow64RevertWow64FsRedirection");

         fWow64Available = pfnDisableWow64 && pfnEnableWow64 && pfnRevertWow64;

Originally posted by thfabba

@wixbot
Copy link
Author

wixbot commented Mar 3, 2015

AssignedTo set to bobarnson
Release changed from v3.x to v3.10

@wixbot
Copy link
Author

wixbot commented Mar 4, 2015

wixtoolset/wix3#218

Originally posted by barnson
Area set to extensions

@wixbot
Copy link
Author

wixbot commented Mar 4, 2015

#wix4

Originally posted by barnson

@wixbot
Copy link
Author

wixbot commented Mar 4, 2015

Originally changed by barnson
Resolution set to fixed
Status changed from Open to Resolved

@wixbot wixbot added this to the v3.10 milestone Dec 20, 2015
@wixbot wixbot closed this as completed Dec 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants