Hardened registry read in settings

This commit is contained in:
Armin Novak 2022-02-15 13:52:12 +01:00 committed by akallabeth
parent 5f8ab14f3f
commit e6877e8135

View File

@ -64,9 +64,9 @@ static BOOL settings_reg_query_dword_val(HKEY hKey, const TCHAR* sub, DWORD* val
dwSize = sizeof(DWORD);
if (RegQueryValueEx(hKey, sub, NULL, &dwType, (BYTE*)value, &dwSize) != ERROR_SUCCESS)
{
return FALSE;
}
if (dwType != REG_DWORD)
return FALSE;
return TRUE;
}
@ -78,6 +78,9 @@ static BOOL settings_reg_query_word_val(HKEY hKey, const TCHAR* sub, UINT16* val
if (!settings_reg_query_dword_val(hKey, sub, &dwValue))
return FALSE;
if (dwValue > UINT16_MAX)
return FALSE;
*value = (UINT16)dwValue;
return TRUE;
}