Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/advapi32/crypt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/dlls/advapi32/crypt.c b/dlls/advapi32/crypt.c index ab1e5982da..87aa8825d0 100644 --- a/dlls/advapi32/crypt.c +++ b/dlls/advapi32/crypt.c @@ -68,11 +68,11 @@ static inline PWSTR CRYPT_GetProvKeyName(PCWSTR pProvName) }; PWSTR keyname;
- keyname = CRYPT_Alloc((strlenW(KEYSTR) + strlenW(pProvName) +1)*sizeof(WCHAR)); + keyname = CRYPT_Alloc((ARRAY_SIZE(KEYSTR) + strlenW(pProvName))*sizeof(WCHAR)); if (keyname) { strcpyW(keyname, KEYSTR); - strcpyW(keyname + strlenW(KEYSTR), pProvName); + strcpyW(keyname + ARRAY_SIZE(KEYSTR) - 1, pProvName); } else SetLastError(ERROR_NOT_ENOUGH_MEMORY); return keyname; @@ -94,14 +94,15 @@ static inline PWSTR CRYPT_GetTypeKeyName(DWORD dwType, BOOL user) 'C','r','y','p','t','o','g','r','a','p','h','y','\', 'P','r','o','v','i','d','e','r',' ','T','y','p','e',' ','X','X','X',0 }; + SIZE_T keyname_size = user ? sizeof(USERSTR) : sizeof(MACHINESTR); PWSTR keyname; PWSTR ptr;
- keyname = CRYPT_Alloc( ((user ? strlenW(USERSTR) : strlenW(MACHINESTR)) +1)*sizeof(WCHAR)); + keyname = CRYPT_Alloc(keyname_size); if (keyname) { user ? strcpyW(keyname, USERSTR) : strcpyW(keyname, MACHINESTR); - ptr = keyname + strlenW(keyname); + ptr = keyname + keyname_size/sizeof(WCHAR) - 1; *(--ptr) = (dwType % 10) + '0'; *(--ptr) = ((dwType / 10) % 10) + '0'; *(--ptr) = (dwType / 100) + '0'; @@ -312,7 +313,7 @@ static void CRYPT_CreateMachineGuid(void) uuid.Data4[6], uuid.Data4[7] ); RegSetValueExW(key, machineGuidW, 0, REG_SZ, (const BYTE *)buf, - (lstrlenW(buf)+1)*sizeof(WCHAR)); + sizeof(buf)); } } RegCloseKey(key);