hellomotor / crashrpt

Automatically exported from code.google.com/p/crashrpt
0 stars 0 forks source link

CErrorReportSender::DumpRegKey issue with REG_BINARY #130

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
You have a simple typo in our source code in method:
int CErrorReportSender::DumpRegKey(HKEY hParentKey, CString sSubKey, 
TiXmlElement* elem)

int j;
for(j=0; j<(int)dwValueLen; j++)
{
   char num[10];
#if _MSC_VER<1400
   sprintf(num, "%02X", pData[i]);
#else
   sprintf_s(num, 10, "%02X", pData[i]);
#endif
   str2 += num;
   if(j<(int)dwValueLen)
      str2 += " ";
}

in for cycle you iterating over 'j' variable, but in body you use 'i' variable.

and i think it's would be good to write CrashSender tests.

And why you using int type for counter. why not size_t or something else 
unsigned?

Original issue reported on code.google.com by gure...@gmail.com on 30 Jan 2012 at 1:16

GoogleCodeExporter commented 9 years ago
Thanks for the report. I'll replace int with size_t or DWORD.

Original comment by zexspect...@gmail.com on 31 Jan 2012 at 1:29

GoogleCodeExporter commented 9 years ago
It seems my report was isn't very clear.
You have a bug in you code.
This report not just about replacing variable typre from one to another.
Dumping of REG_BINARY now isn't working cuz you have a mistake(typo).

BEFORE:
int j;
for(j=0; j<(int)dwValueLen; j++)
{
   char num[10];
#if _MSC_VER<1400
   sprintf(num, "%02X", pData[i]);
#else
   sprintf_s(num, 10, "%02X", pData[i]);
#endif
   str2 += num;
   if(j<(int)dwValueLen)
      str2 += " ";
}

AFTER:
int j;
for(j=0; j<(int)dwValueLen; j++)
{
   char num[10];
#if _MSC_VER<1400
   sprintf(num, "%02X", pData[j]);
#else
   sprintf_s(num, 10, "%02X", pData[j]);
#endif
   str2 += num;
   if(j<(int)dwValueLen)
      str2 += " ";
}

Original comment by gure...@gmail.com on 5 Mar 2012 at 6:14

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1356.

Original comment by zexspect...@gmail.com on 26 Aug 2012 at 6:17