crypt32: Don't copy past end of buffer when removing the last string in a multistring.
This commit is contained in:
parent
2768710c36
commit
88e599c4cf
|
@ -873,9 +873,18 @@ static BOOL CRYPT_RemoveStringFromMultiString(LPWSTR multi, LPCWSTR toRemove)
|
||||||
{
|
{
|
||||||
DWORD len = CRYPT_GetMultiStringCharacterLen(multi);
|
DWORD len = CRYPT_GetMultiStringCharacterLen(multi);
|
||||||
|
|
||||||
/* Copy remainder of string "left" */
|
if (spotToRemove + lstrlenW(toRemove) + 2 >= multi + len)
|
||||||
memmove(spotToRemove, spotToRemove + lstrlenW(toRemove) + 1,
|
{
|
||||||
(len - (spotToRemove - multi)) * sizeof(WCHAR));
|
/* 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;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue