From 1c32c2acc905c177f5f76a6a7ba0727ab698727d Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 30 Jun 2004 21:20:19 +0000 Subject: [PATCH] fix off-by-one bug in proc_args --- src/os/win32/win32_sigar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index e37270dd..0d3580f4 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -141,6 +141,7 @@ int sigar_os_open(sigar_t **sigar) version.dwOSVersionInfoSize = sizeof(version); GetVersionEx(&version); + (*sigar)->winnt = (version.dwPlatformId == VER_PLATFORM_WIN32_NT); @@ -865,6 +866,8 @@ static int sigar_remote_proc_args_get(sigar_t *sigar, sigar_pid_t pid, return GetLastError(); } + datalen++; /* we want the \0 terminator too */ + cmdline = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, datalen); @@ -875,7 +878,7 @@ static int sigar_remote_proc_args_get(sigar_t *sigar, sigar_pid_t pid, } if (ReadProcessMemory(proc, data, cmdline, - datalen+1, &bytes)) + datalen, &bytes)) { char *arg, *ptr = cmdline;