Skip to content
Snippets Groups Projects
Commit 8cedc805 authored by Michael Roth's avatar Michael Roth
Browse files

qga-win: fix error-handling in getNameByStringSID()


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: default avatarChen Hanxiao <chenhanxiao@gmail.com>
Suggested-by: default avatarTomáš Golembiovský <tgolembi@redhat.com>
Signed-off-by: default avatarMichael Roth <mdroth@linux.vnet.ibm.com>
parent 53f9fcb2
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment