James Hawkins wrote:
PWSTR keyname;
- keyname = CRYPT_Alloc(strlen(KEYSTR) + strlen(pProvName) +1);
if (keyname) {keyname = CRYPT_Alloc((strlenW(KEYSTR) + strlenW(pProvName) + 1) * sizeof(WCHAR));
strcpy(keyname, KEYSTR);
strcpy(keyname + strlen(KEYSTR), pProvName);
strcpyW(keyname, KEYSTR);
} else SetLastError(ERROR_NOT_ENOUGH_MEMORY); return keyname;strcpyW(keyname + strlenW(KEYSTR) * sizeof(WCHAR), pProvName);
}
This doesn't look right.... when using pointer arithmetic, you do so in increments of the pointer's type (eg. WCHAR). The following two lines are the same, and are both wrong:
strcpyW(keyname + strlenW(KEYSTR) * sizeof(WCHAR), pProvName); strcpyW(&keyname[strlenW(KEYSTR) * sizeof(WCHAR)], pProvName);
The right version would be:
strcpyW(&keyname[strlenW(KEYSTR)], pProvName);
but how about just using:
strcatW( keyname, pProvname );
Mike