mirror of
https://github.com/reactos/reactos.git
synced 2025-05-23 11:04:52 +00:00
Fix buffer read past end problem. (#5146)
Fixes crashes in regedit-find affecting CORE-15896 and CORE-18230. After possible RegQueryValueExW append 3 zero bytes to guarantee that we will end with a UNICODE NULL.
This commit is contained in:
parent
44b2a46d03
commit
cce3eb9393
1 changed files with 6 additions and 1 deletions
|
@ -223,7 +223,7 @@ BOOL RegFindRecurse(
|
|||
NULL, &cb);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
goto err;
|
||||
pb = malloc(cb);
|
||||
pb = malloc(cb + 3); /* To avoid buffer overrun, append 3 NULs */
|
||||
if (pb == NULL)
|
||||
goto err;
|
||||
lResult = RegQueryValueExW(hSubKey, ppszNames[i], NULL, &type,
|
||||
|
@ -231,6 +231,11 @@ BOOL RegFindRecurse(
|
|||
if (lResult != ERROR_SUCCESS)
|
||||
goto err;
|
||||
|
||||
/* To avoid buffer overrun, append 3 NUL bytes.
|
||||
NOTE: cb can be an odd number although UNICODE_NULL is two bytes.
|
||||
Two bytes at odd position is not enough to avoid buffer overrun. */
|
||||
pb[cb] = pb[cb + 1] = pb[cb + 2] = 0;
|
||||
|
||||
if ((s_dwFlags & RSF_LOOKATDATA) &&
|
||||
CompareData(type, (LPWSTR) pb, s_szFindWhat))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue