aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/acl2util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dutil/acl2util.cpp')
-rw-r--r--src/dutil/acl2util.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/dutil/acl2util.cpp b/src/dutil/acl2util.cpp
index 5aba60f0..598f12e7 100644
--- a/src/dutil/acl2util.cpp
+++ b/src/dutil/acl2util.cpp
@@ -23,7 +23,7 @@ NOTE: psczSid should be freed with StrFree()
23********************************************************************/ 23********************************************************************/
24extern "C" HRESULT DAPI AclCalculateServiceSidString( 24extern "C" HRESULT DAPI AclCalculateServiceSidString(
25 __in LPCWSTR wzServiceName, 25 __in LPCWSTR wzServiceName,
26 __in int cchServiceName, 26 __in SIZE_T cchServiceName,
27 __deref_out_z LPWSTR* psczSid 27 __deref_out_z LPWSTR* psczSid
28 ) 28 )
29{ 29{
@@ -39,7 +39,7 @@ extern "C" HRESULT DAPI AclCalculateServiceSidString(
39 39
40 if (0 == cchServiceName) 40 if (0 == cchServiceName)
41 { 41 {
42 hr = ::StringCchLengthW(wzServiceName, INT_MAX, reinterpret_cast<size_t*>(&cchServiceName)); 42 hr = ::StringCchLengthW(wzServiceName, STRSAFE_MAX_CCH, reinterpret_cast<size_t*>(&cchServiceName));
43 AclExitOnFailure(hr, "Failed to get the length of the service name."); 43 AclExitOnFailure(hr, "Failed to get the length of the service name.");
44 } 44 }
45 45
@@ -49,7 +49,7 @@ extern "C" HRESULT DAPI AclCalculateServiceSidString(
49 pbHash = reinterpret_cast<BYTE*>(MemAlloc(cbHash, TRUE)); 49 pbHash = reinterpret_cast<BYTE*>(MemAlloc(cbHash, TRUE));
50 AclExitOnNull(pbHash, hr, E_OUTOFMEMORY, "Failed to allocate hash byte array."); 50 AclExitOnNull(pbHash, hr, E_OUTOFMEMORY, "Failed to allocate hash byte array.");
51 51
52 hr = CrypHashBuffer(reinterpret_cast<BYTE*>(sczUpperServiceName), cchServiceName * 2, PROV_RSA_FULL, CALG_SHA1, pbHash, cbHash); 52 hr = CrypHashBuffer(reinterpret_cast<BYTE*>(sczUpperServiceName), cchServiceName * sizeof(WCHAR), PROV_RSA_FULL, CALG_SHA1, pbHash, cbHash);
53 AclExitOnNull(pbHash, hr, E_OUTOFMEMORY, "Failed to hash the service name."); 53 AclExitOnNull(pbHash, hr, E_OUTOFMEMORY, "Failed to hash the service name.");
54 54
55 hr = StrAllocFormatted(psczSid, L"S-1-5-80-%u-%u-%u-%u-%u", 55 hr = StrAllocFormatted(psczSid, L"S-1-5-80-%u-%u-%u-%u-%u",
@@ -80,7 +80,7 @@ extern "C" HRESULT DAPI AclGetAccountSidStringEx(
80 ) 80 )
81{ 81{
82 HRESULT hr = S_OK; 82 HRESULT hr = S_OK;
83 int cchAccount = 0; 83 SIZE_T cchAccount = 0;
84 PSID psid = NULL; 84 PSID psid = NULL;
85 LPWSTR pwz = NULL; 85 LPWSTR pwz = NULL;
86 LPWSTR sczSid = NULL; 86 LPWSTR sczSid = NULL;
@@ -103,7 +103,7 @@ extern "C" HRESULT DAPI AclGetAccountSidStringEx(
103 { 103 {
104 if (HRESULT_FROM_WIN32(ERROR_NONE_MAPPED) == hr) 104 if (HRESULT_FROM_WIN32(ERROR_NONE_MAPPED) == hr)
105 { 105 {
106 HRESULT hrLength = ::StringCchLengthW(wzAccount, INT_MAX, reinterpret_cast<size_t*>(&cchAccount)); 106 HRESULT hrLength = ::StringCchLengthW(wzAccount, STRSAFE_MAX_CCH, reinterpret_cast<size_t*>(&cchAccount));
107 AclExitOnFailure(hrLength, "Failed to get the length of the account name."); 107 AclExitOnFailure(hrLength, "Failed to get the length of the account name.");
108 108
109 if (11 < cchAccount && CSTR_EQUAL == CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, L"NT SERVICE\\", 11, wzAccount, 11)) 109 if (11 < cchAccount && CSTR_EQUAL == CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, L"NT SERVICE\\", 11, wzAccount, 11))