]> Git Repo - qemu.git/commitdiff
qga-win: fix error-handling in getNameByStringSID()
authorMichael Roth <[email protected]>
Fri, 27 Oct 2017 00:53:45 +0000 (19:53 -0500)
committerMichael Roth <[email protected]>
Fri, 27 Oct 2017 01:01:32 +0000 (20:01 -0500)
In one case we misconstrue a BOOL return as an HRESULT, and in the
other case we don't check the BOOL return from LookupAccountSidW()
before extracting the HRESULT from GetLastError(). Both can lead to
getNameByStringSID() misreporting an error.

Reported-by: Chen Hanxiao <[email protected]>
Suggested-by: Tomáš Golembiovský <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
qga/vss-win32/install.cpp

index ba7c94eb256b05f285de39ec7bcd5220b27cbffa..6713e58670f3ff0626f8b2cb82520a4c24629a21 100644 (file)
@@ -148,10 +148,15 @@ static HRESULT getNameByStringSID(
     DWORD domainNameLen = BUFFER_SIZE;
     wchar_t domainName[BUFFER_SIZE];
 
-    chk(ConvertStringSidToSidW(sid, &psid));
-    LookupAccountSidW(NULL, psid, buffer, bufferLen,
-                domainName, &domainNameLen, &groupType);
-    hr = HRESULT_FROM_WIN32(GetLastError());
+    if (!ConvertStringSidToSidW(sid, &psid)) {
+        hr = HRESULT_FROM_WIN32(GetLastError());
+        goto out;
+    }
+    if (!LookupAccountSidW(NULL, psid, buffer, bufferLen,
+                           domainName, &domainNameLen, &groupType)) {
+        hr = HRESULT_FROM_WIN32(GetLastError());
+        /* Fall through and free psid */
+    }
 
     LocalFree(psid);
 
This page took 0.02744 seconds and 4 git commands to generate.