diff options
| author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-02-10 16:57:11 +0000 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-02-10 16:57:11 +0000 |
| commit | 0866680bd904aff4fe2a643a2b81c460cbb99c77 (patch) | |
| tree | 242dae052199994a35f5e68578661175241a0a71 /src/network/kernel/qnetworkproxy_win.cpp | |
| parent | 34ea269b3b173498312b0203d6875ef3b4ba0253 (diff) | |
| parent | fc35f714340d5361231506dfbead132122f59460 (diff) | |
Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev
Diffstat (limited to 'src/network/kernel/qnetworkproxy_win.cpp')
| -rw-r--r-- | src/network/kernel/qnetworkproxy_win.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp index f7741ce86a5..91f7ac36cfe 100644 --- a/src/network/kernel/qnetworkproxy_win.cpp +++ b/src/network/kernel/qnetworkproxy_win.cpp @@ -130,10 +130,17 @@ static bool currentProcessIsService() DWORD size = UNLEN; if (ptrGetUserName(userName, &size)) { SID_NAME_USE type = SidTypeUser; - DWORD dummy = MAX_PATH; - wchar_t dummyStr[MAX_PATH] = L""; - PSID psid = 0; - if (ptrLookupAccountName(NULL, userName, &psid, &dummy, dummyStr, &dummy, &type)) + DWORD sidSize = 0; + DWORD domainSize = 0; + // first call is to get the correct size + bool bRet = ptrLookupAccountName(NULL, userName, NULL, &sidSize, NULL, &domainSize, &type); + if (bRet == FALSE && ERROR_INSUFFICIENT_BUFFER != GetLastError()) + return false; + QVarLengthArray<BYTE, 68> buff(sidSize); + QVarLengthArray<wchar_t, MAX_PATH> domainName(domainSize); + // second call to LookupAccountNameW actually gets the SID + // both the pointer to the buffer and the pointer to the domain name should not be NULL + if (ptrLookupAccountName(NULL, userName, buff.data(), &sidSize, domainName.data(), &domainSize, &type)) return type != SidTypeUser; //returns true if the current user is not a user } } |
