service->username = 0;\r
service->usernamelen = 0;\r
}\r
- else if (! orig_service || ! orig_service->username || ! str_equiv(service->username, orig_service->username)) {\r
+ else {\r
/* Password. */\r
service->passwordlen = SendMessage(GetDlgItem(tablist[NSSM_TAB_LOGON], IDC_PASSWORD1), WM_GETTEXTLENGTH, 0, 0);\r
- if (! service->passwordlen) {\r
- popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);\r
- return 6;\r
- }\r
- if (SendMessage(GetDlgItem(tablist[NSSM_TAB_LOGON], IDC_PASSWORD2), WM_GETTEXTLENGTH, 0, 0) != service->passwordlen) {\r
- popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);\r
- return 6;\r
- }\r
- service->passwordlen++;\r
-\r
- /* Temporary buffer for password validation. */\r
- TCHAR *password = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, service->passwordlen * sizeof(TCHAR));\r
- if (! password) {\r
- HeapFree(GetProcessHeap(), 0, service->username);\r
- service->username = 0;\r
- service->usernamelen = 0;\r
- popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("password confirmation"), _T("install()"));\r
- return 6;\r
- }\r
+ size_t passwordlen = SendMessage(GetDlgItem(tablist[NSSM_TAB_LOGON], IDC_PASSWORD2), WM_GETTEXTLENGTH, 0, 0);\r
\r
- /* Actual password buffer. */\r
- service->password = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, service->passwordlen * sizeof(TCHAR));\r
- if (! service->password) {\r
- HeapFree(GetProcessHeap(), 0, password);\r
- HeapFree(GetProcessHeap(), 0, service->username);\r
- service->username = 0;\r
- service->usernamelen = 0;\r
- popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("password"), _T("install()"));\r
- return 6;\r
- }\r
+ if (! orig_service || ! orig_service->username || ! str_equiv(service->username, orig_service->username) || service->passwordlen || passwordlen) {\r
+ if (! service->passwordlen) {\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);\r
+ return 6;\r
+ }\r
+ if (passwordlen != service->passwordlen) {\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);\r
+ return 6;\r
+ }\r
+ service->passwordlen++;\r
+\r
+ /* Temporary buffer for password validation. */\r
+ TCHAR *password = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, service->passwordlen * sizeof(TCHAR));\r
+ if (! password) {\r
+ HeapFree(GetProcessHeap(), 0, service->username);\r
+ service->username = 0;\r
+ service->usernamelen = 0;\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("password confirmation"), _T("install()"));\r
+ return 6;\r
+ }\r
\r
- /* 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
- HeapFree(GetProcessHeap(), 0, service->password);\r
- service->password = 0;\r
- service->passwordlen = 0;\r
- HeapFree(GetProcessHeap(), 0, service->username);\r
- service->username = 0;\r
- service->usernamelen = 0;\r
- popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_PASSWORD);\r
- return 6;\r
- }\r
+ /* Actual password buffer. */\r
+ service->password = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, service->passwordlen * sizeof(TCHAR));\r
+ if (! service->password) {\r
+ HeapFree(GetProcessHeap(), 0, password);\r
+ HeapFree(GetProcessHeap(), 0, service->username);\r
+ service->username = 0;\r
+ service->usernamelen = 0;\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("password"), _T("install()"));\r
+ return 6;\r
+ }\r
\r
- /* Get confirmation. */\r
- if (! GetDlgItemText(tablist[NSSM_TAB_LOGON], IDC_PASSWORD2, password, (int) service->passwordlen)) {\r
- SecureZeroMemory(password, service->passwordlen);\r
- HeapFree(GetProcessHeap(), 0, password);\r
- SecureZeroMemory(service->password, service->passwordlen);\r
- HeapFree(GetProcessHeap(), 0, service->password);\r
- service->password = 0;\r
- service->passwordlen = 0;\r
- HeapFree(GetProcessHeap(), 0, service->username);\r
- service->username = 0;\r
- service->usernamelen = 0;\r
- popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_PASSWORD);\r
- return 6;\r
- }\r
+ /* 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
+ HeapFree(GetProcessHeap(), 0, service->password);\r
+ service->password = 0;\r
+ service->passwordlen = 0;\r
+ HeapFree(GetProcessHeap(), 0, service->username);\r
+ service->username = 0;\r
+ service->usernamelen = 0;\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_PASSWORD);\r
+ return 6;\r
+ }\r
\r
- /* Compare. */\r
- if (_tcsncmp(password, service->password, service->passwordlen)) {\r
- popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);\r
- SecureZeroMemory(password, service->passwordlen);\r
- HeapFree(GetProcessHeap(), 0, password);\r
- SecureZeroMemory(service->password, service->passwordlen);\r
- HeapFree(GetProcessHeap(), 0, service->password);\r
- service->password = 0;\r
- service->passwordlen = 0;\r
- HeapFree(GetProcessHeap(), 0, service->username);\r
- service->username = 0;\r
- service->usernamelen = 0;\r
- return 6;\r
+ /* Get confirmation. */\r
+ if (! GetDlgItemText(tablist[NSSM_TAB_LOGON], IDC_PASSWORD2, password, (int) service->passwordlen)) {\r
+ SecureZeroMemory(password, service->passwordlen);\r
+ HeapFree(GetProcessHeap(), 0, password);\r
+ SecureZeroMemory(service->password, service->passwordlen);\r
+ HeapFree(GetProcessHeap(), 0, service->password);\r
+ service->password = 0;\r
+ service->passwordlen = 0;\r
+ HeapFree(GetProcessHeap(), 0, service->username);\r
+ service->username = 0;\r
+ service->usernamelen = 0;\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_PASSWORD);\r
+ return 6;\r
+ }\r
+\r
+ /* Compare. */\r
+ if (_tcsncmp(password, service->password, service->passwordlen)) {\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);\r
+ SecureZeroMemory(password, service->passwordlen);\r
+ HeapFree(GetProcessHeap(), 0, password);\r
+ SecureZeroMemory(service->password, service->passwordlen);\r
+ HeapFree(GetProcessHeap(), 0, service->password);\r
+ service->password = 0;\r
+ service->passwordlen = 0;\r
+ HeapFree(GetProcessHeap(), 0, service->username);\r
+ service->username = 0;\r
+ service->usernamelen = 0;\r
+ return 6;\r
+ }\r
}\r
}\r
}\r
cleanup_nssm_service(service);\r
return 4;\r
\r
+ case 5:\r
case 6:\r
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_EDIT_PARAMETERS_FAILED);\r
cleanup_nssm_service(service);\r