NUL terminate messages received from interactive service

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/86/head
Selva Nair 2016-06-22 21:48:19 -04:00
parent 9ed9abec4f
commit 9892d5813f
1 changed files with 6 additions and 1 deletions

View File

@ -658,10 +658,15 @@ HandleServiceIO (DWORD err, DWORD bytes, LPOVERLAPPED lpo)
int len, capacity;
len = _countof(s->readbuf);
capacity = len*sizeof(*(s->readbuf));
capacity = (len-1)*sizeof(*(s->readbuf));
if (bytes > 0)
{
/* messages from the service are not nul terminated */
int nchars = bytes/sizeof(s->readbuf[0]);
s->readbuf[nchars] = L'\0';
SetEvent (s->hEvent);
}
if (err)
{
_snwprintf(s->readbuf, len, L"0x%08x\nInteractive Service disconnected\n", err);