service->passwordlen is a count of TCHARs, fix SecureZeroMemory for UNICODE
authorDavid Bremner <dbremner@gmail.com>
Mon, 4 Jul 2016 21:35:06 +0000 (14:35 -0700)
committerIain Patterson <me@iain.cx>
Tue, 5 Jul 2016 09:03:44 +0000 (10:03 +0100)
gui.cpp
service.cpp

diff --git a/gui.cpp b/gui.cpp
index 07a7d9d..79000a1 100644 (file)
--- a/gui.cpp
+++ b/gui.cpp
@@ -450,7 +450,7 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
     service->username = 0;\r
     service->usernamelen = 0;\r
     if (service->password) {\r
-      SecureZeroMemory(service->password, service->passwordlen);\r
+      SecureZeroMemory(service->password, service->passwordlen * sizeof(TCHAR));\r
       HeapFree(GetProcessHeap(), 0, service->password);\r
     }\r
     service->password = 0;\r
@@ -539,7 +539,7 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
         /* Get first password. */\r
         if (! GetDlgItemText(tablist[NSSM_TAB_LOGON], IDC_PASSWORD1, service->password, (int) service->passwordlen)) {\r
           HeapFree(GetProcessHeap(), 0, password);\r
-          SecureZeroMemory(service->password, service->passwordlen);\r
+          SecureZeroMemory(service->password, service->passwordlen * sizeof(TCHAR));\r
           HeapFree(GetProcessHeap(), 0, service->password);\r
           service->password = 0;\r
           service->passwordlen = 0;\r
@@ -552,9 +552,9 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
 \r
         /* Get confirmation. */\r
         if (! GetDlgItemText(tablist[NSSM_TAB_LOGON], IDC_PASSWORD2, password, (int) service->passwordlen)) {\r
-          SecureZeroMemory(password, service->passwordlen);\r
+          SecureZeroMemory(password, service->passwordlen * sizeof(TCHAR));\r
           HeapFree(GetProcessHeap(), 0, password);\r
-          SecureZeroMemory(service->password, service->passwordlen);\r
+          SecureZeroMemory(service->password, service->passwordlen * sizeof(TCHAR));\r
           HeapFree(GetProcessHeap(), 0, service->password);\r
           service->password = 0;\r
           service->passwordlen = 0;\r
@@ -568,9 +568,9 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
         /* Compare. */\r
         if (_tcsncmp(password, service->password, service->passwordlen)) {\r
           popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);\r
-          SecureZeroMemory(password, service->passwordlen);\r
+          SecureZeroMemory(password, service->passwordlen * sizeof(TCHAR));\r
           HeapFree(GetProcessHeap(), 0, password);\r
-          SecureZeroMemory(service->password, service->passwordlen);\r
+          SecureZeroMemory(service->password, service->passwordlen * sizeof(TCHAR));\r
           HeapFree(GetProcessHeap(), 0, service->password);\r
           service->password = 0;\r
           service->passwordlen = 0;\r
index ce3fb92..bc3a471 100644 (file)
@@ -760,7 +760,7 @@ void cleanup_nssm_service(nssm_service_t *service) {
   if (! service) return;\r
   if (service->username) HeapFree(GetProcessHeap(), 0, service->username);\r
   if (service->password) {\r
-    SecureZeroMemory(service->password, service->passwordlen);\r
+    SecureZeroMemory(service->password, service->passwordlen * sizeof(TCHAR));\r
     HeapFree(GetProcessHeap(), 0, service->password);\r
   }\r
   if (service->dependencies) HeapFree(GetProcessHeap(), 0, service->dependencies);\r