From: Iain Patterson Date: Tue, 26 Nov 2013 11:13:42 +0000 (+0000) Subject: Be less paranoid. X-Git-Tag: v2.22~135 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=ef26a193bb671cd22d498839f205a0ec4523518e;p=nssm.git Be less paranoid. We were checking that the path to our executable was within MAX_PATH but it must be by definition and we have been safely skipping the check elsewhere. --- diff --git a/service.cpp b/service.cpp index fc9b73c..294497a 100644 --- a/service.cpp +++ b/service.cpp @@ -142,20 +142,8 @@ int install_service(nssm_service_t *service) { } /* Get path of this program */ - TCHAR path[MAX_PATH]; - GetModuleFileName(0, path, MAX_PATH); - - /* Construct command */ - TCHAR command[CMD_LENGTH]; - size_t pathlen = _tcslen(path); - if (pathlen + 1 >= VALUE_LENGTH) { - print_message(stderr, NSSM_MESSAGE_PATH_TOO_LONG, NSSM); - return 3; - } - if (_sntprintf_s(command, sizeof(command), _TRUNCATE, _T("\"%s\""), path) < 0) { - print_message(stderr, NSSM_MESSAGE_OUT_OF_MEMORY_FOR_IMAGEPATH); - return 4; - } + TCHAR command[MAX_PATH]; + GetModuleFileName(0, command, _countof(command)); /* Create the service */ service->handle = CreateService(services, service->name, service->name, SC_MANAGER_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, command, 0, 0, 0, 0, 0);