Must pass count of TCHARs to _LogData2Hex so we don't overflow the buffer in unicode stubs

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6468 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2014-05-08 20:12:26 +00:00
parent d2f4cf6c2a
commit a03795783a
3 changed files with 10 additions and 17 deletions

View file

@ -947,22 +947,16 @@ const TCHAR * _RegKeyHandleToName(HKEY hKey)
return _T("invalid registry key");
}
void _LogData2Hex(TCHAR *buf, size_t buflen, BYTE *data, size_t datalen)
void _LogData2Hex(TCHAR *buf, size_t cchbuf, BYTE *data, size_t cbdata)
{
TCHAR *p = buf;
size_t i;
int dots = 0;
size_t bufbytes = buflen / 3; // 2 hex digits, one space/null
size_t i, bufbytes = cchbuf / 3; // 2 hex digits, one space/null
if (datalen > bufbytes)
{
bufbytes--;
dots = 1;
}
if (cbdata > bufbytes)
bufbytes--, dots++;
else
bufbytes = datalen;
bufbytes = cbdata;
for (i = 0; i < bufbytes; i++)
{
@ -970,8 +964,7 @@ void _LogData2Hex(TCHAR *buf, size_t buflen, BYTE *data, size_t datalen)
p += 3;
}
if (dots)
mystrcat(buf, _T("..."));
if (dots) mystrcat(buf, _T("..."));
}
#ifdef NSIS_CONFIG_LOG_TIMESTAMP