From: David Bremner Date: Mon, 4 Jul 2016 21:35:06 +0000 (-0700) Subject: service->passwordlen is a count of TCHARs, fix SecureZeroMemory for UNICODE X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=fe0f3a497b3ab024c4471458e9c8b9a07388750c;p=nssm.git service->passwordlen is a count of TCHARs, fix SecureZeroMemory for UNICODE --- diff --git a/gui.cpp b/gui.cpp index 07a7d9d..79000a1 100644 --- 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; service->usernamelen = 0; if (service->password) { - SecureZeroMemory(service->password, service->passwordlen); + SecureZeroMemory(service->password, service->passwordlen * sizeof(TCHAR)); HeapFree(GetProcessHeap(), 0, service->password); } service->password = 0; @@ -539,7 +539,7 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service /* Get first password. */ if (! GetDlgItemText(tablist[NSSM_TAB_LOGON], IDC_PASSWORD1, service->password, (int) service->passwordlen)) { HeapFree(GetProcessHeap(), 0, password); - SecureZeroMemory(service->password, service->passwordlen); + SecureZeroMemory(service->password, service->passwordlen * sizeof(TCHAR)); HeapFree(GetProcessHeap(), 0, service->password); service->password = 0; service->passwordlen = 0; @@ -552,9 +552,9 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service /* Get confirmation. */ if (! GetDlgItemText(tablist[NSSM_TAB_LOGON], IDC_PASSWORD2, password, (int) service->passwordlen)) { - SecureZeroMemory(password, service->passwordlen); + SecureZeroMemory(password, service->passwordlen * sizeof(TCHAR)); HeapFree(GetProcessHeap(), 0, password); - SecureZeroMemory(service->password, service->passwordlen); + SecureZeroMemory(service->password, service->passwordlen * sizeof(TCHAR)); HeapFree(GetProcessHeap(), 0, service->password); service->password = 0; service->passwordlen = 0; @@ -568,9 +568,9 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service /* Compare. */ if (_tcsncmp(password, service->password, service->passwordlen)) { popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD); - SecureZeroMemory(password, service->passwordlen); + SecureZeroMemory(password, service->passwordlen * sizeof(TCHAR)); HeapFree(GetProcessHeap(), 0, password); - SecureZeroMemory(service->password, service->passwordlen); + SecureZeroMemory(service->password, service->passwordlen * sizeof(TCHAR)); HeapFree(GetProcessHeap(), 0, service->password); service->password = 0; service->passwordlen = 0; diff --git a/service.cpp b/service.cpp index ce3fb92..bc3a471 100644 --- a/service.cpp +++ b/service.cpp @@ -760,7 +760,7 @@ void cleanup_nssm_service(nssm_service_t *service) { if (! service) return; if (service->username) HeapFree(GetProcessHeap(), 0, service->username); if (service->password) { - SecureZeroMemory(service->password, service->passwordlen); + SecureZeroMemory(service->password, service->passwordlen * sizeof(TCHAR)); HeapFree(GetProcessHeap(), 0, service->password); } if (service->dependencies) HeapFree(GetProcessHeap(), 0, service->dependencies);