mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 23:25:48 +00:00
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:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user