From 8eb06fa6975594488aad2dc30d5d7d3011c54ebb Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Fri, 13 Oct 2017 23:37:17 -0400 Subject: [PATCH] Correct parsing of the process ID returned by interatcive service Signed-off-by: Selva Nair --- openvpn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openvpn.c b/openvpn.c index ea6726c..f080c67 100644 --- a/openvpn.c +++ b/openvpn.c @@ -1173,7 +1173,8 @@ OnService(connection_t *c, UNUSED char *msg) } p = buf + 11; - if (!err && swscanf (p, L"0x%08x\nProcess ID", &pid) == 1 && pid != 0) + /* next line is the pid if followed by "\nProcess ID" */ + if (!err && wcsstr(p, L"\nProcess ID") && swscanf (p, L"0x%08x", &pid) == 1 && pid != 0) { PrintDebug (L"Process ID of openvpn started by IService: %d", pid); c->hProcess = OpenProcess (PROCESS_TERMINATE|PROCESS_QUERY_INFORMATION, FALSE, pid);