mirror of https://github.com/OpenVPN/openvpn-gui
NUL terminate messages received from interactive service
Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/86/head
parent
9ed9abec4f
commit
9892d5813f
|
@ -658,10 +658,15 @@ HandleServiceIO (DWORD err, DWORD bytes, LPOVERLAPPED lpo)
|
||||||
int len, capacity;
|
int len, capacity;
|
||||||
|
|
||||||
len = _countof(s->readbuf);
|
len = _countof(s->readbuf);
|
||||||
capacity = len*sizeof(*(s->readbuf));
|
capacity = (len-1)*sizeof(*(s->readbuf));
|
||||||
|
|
||||||
if (bytes > 0)
|
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);
|
SetEvent (s->hEvent);
|
||||||
|
}
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
_snwprintf(s->readbuf, len, L"0x%08x\nInteractive Service disconnected\n", err);
|
_snwprintf(s->readbuf, len, L"0x%08x\nInteractive Service disconnected\n", err);
|
||||||
|
|
Loading…
Reference in New Issue