crypt32: Don't copy past end of buffer when removing the last string in a multistring.

This commit is contained in:
Juan Lang 2009-11-04 16:29:33 -08:00 committed by Alexandre Julliard
parent 2768710c36
commit 88e599c4cf
1 changed files with 12 additions and 3 deletions

View File

@ -873,9 +873,18 @@ static BOOL CRYPT_RemoveStringFromMultiString(LPWSTR multi, LPCWSTR toRemove)
{
DWORD len = CRYPT_GetMultiStringCharacterLen(multi);
/* Copy remainder of string "left" */
memmove(spotToRemove, spotToRemove + lstrlenW(toRemove) + 1,
(len - (spotToRemove - multi)) * sizeof(WCHAR));
if (spotToRemove + lstrlenW(toRemove) + 2 >= multi + len)
{
/* Removing last string in list, terminate multi string directly */
*spotToRemove = 0;
*(spotToRemove + 1) = 0;
}
else
{
/* Copy remainder of string "left" */
memmove(spotToRemove, spotToRemove + lstrlenW(toRemove) + 1,
(len - (spotToRemove - multi)) * sizeof(WCHAR));
}
ret = TRUE;
}
else