For any registry key, CErrorReportSender::DumpRegKey() doesn't dump the subkey
with the longest name or the value with the longest name.
To reproduce, create the following registry keys and values and then call
CErrorReportSender::DumpRegKey() for TopLevelKey.
[HKEY_CURRENT_USER\Software\TestApp\TopLevelKey]
"Value_BugTest_XYZ"="abcd"
"Value_BugTest_XYZABC"="efgh"
[HKEY_CURRENT_USER\Software\TestApp\TopLevelKey\SubKey_BugTest]
[HKEY_CURRENT_USER\Software\TestApp\TopLevelKey\SubKey_BugTest_ABC]
Expected result: it should dump two sub keys and two values.
Actual result: It omits subkey "SubKey_BugTest_ABC" and value
"Value_BugTest_XYZABC".
Cause:
CErrorReportSender::DumpRegKey() uses RegQueryInfoKey() to determine the size
of the subkey with the longest name and the size of the longest value name.
Note that both of these sizes do not include the size of the terminating null
character (see MSDN docs for RegQueryInfoKey).
CErrorReportSender::DumpRegKey() then later uses these sizes to allocate
buffers when calling RegEnumKeyEx() and RegEnumValue() but fails to take into
account that the buffers need to include for the terminating null character.
The result is that RegEnumKeyEx() and RegEnumValue() both end up returning
ERROR_MORE_DATA for the subkey or value with the longest name.
Suggested solution:
In CErrorReportSender::DumpRegKey(HKEY , CString , TiXmlElement*) add some
"+1"s as follows:
change this code:-
LPWSTR szName = new WCHAR[dwMaxSubKey];
DWORD dwLen = dwMaxSubKey;
lResult = RegEnumKeyEx(hKey, i, szName, &dwLen, 0, NULL, 0, NULL);
to:
LPWSTR szName = new WCHAR[dwMaxSubKey + 1];
DWORD dwLen = dwMaxSubKey + 1;
lResult = RegEnumKeyEx(hKey, i, szName, &dwLen, 0, NULL, 0, NULL);
and change this code:
LPWSTR szName = new WCHAR[dwMaxValueNameLen];
LPBYTE pData = new BYTE[dwMaxValueLen];
DWORD dwNameLen = dwMaxValueNameLen;
DWORD dwValueLen = dwMaxValueLen;
DWORD dwType = 0;
lResult = RegEnumValue(hKey, i, szName, &dwNameLen, 0, &dwType, pData,
&dwValueLen);
to:
LPWSTR szName = new WCHAR[dwMaxValueNameLen + 1];
LPBYTE pData = new BYTE[dwMaxValueLen];
DWORD dwNameLen = dwMaxValueNameLen + 1;
DWORD dwValueLen = dwMaxValueLen;
DWORD dwType = 0;
lResult = RegEnumValue(hKey, i, szName, &dwNameLen, 0, &dwType, pData,
&dwValueLen);
CrashRpt v1.3.0
Visual Studio 2008
Windows 7 Pro 64-Bit
Original issue reported on code.google.com by peter.j....@googlemail.com on 2 Aug 2012 at 9:47
Original issue reported on code.google.com by
peter.j....@googlemail.com
on 2 Aug 2012 at 9:47