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: Chen Hanxiao <chenhanxiao@gmail.com> Suggested-by: Tomáš Golembiovský <tgolembi@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
parent
53f9fcb263
commit
8cedc80555
@ -148,10 +148,15 @@ static HRESULT getNameByStringSID(
|
|||||||
DWORD domainNameLen = BUFFER_SIZE;
|
DWORD domainNameLen = BUFFER_SIZE;
|
||||||
wchar_t domainName[BUFFER_SIZE];
|
wchar_t domainName[BUFFER_SIZE];
|
||||||
|
|
||||||
chk(ConvertStringSidToSidW(sid, &psid));
|
if (!ConvertStringSidToSidW(sid, &psid)) {
|
||||||
LookupAccountSidW(NULL, psid, buffer, bufferLen,
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||||
domainName, &domainNameLen, &groupType);
|
goto out;
|
||||||
hr = HRESULT_FROM_WIN32(GetLastError());
|
}
|
||||||
|
if (!LookupAccountSidW(NULL, psid, buffer, bufferLen,
|
||||||
|
domainName, &domainNameLen, &groupType)) {
|
||||||
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||||
|
/* Fall through and free psid */
|
||||||
|
}
|
||||||
|
|
||||||
LocalFree(psid);
|
LocalFree(psid);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user