X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=gui.cpp;h=84fd4c26df98c12f175f67d3d6264ae710247ad9;hb=e42e6900a5dad50b952d92c57344fdea2e13646e;hp=97c69a8da5c6ca0a96929d2e5455380eb5f8ce4d;hpb=f2ec1c0c55a6b3e8ca02b3d66b78c87fe0ac1f47;p=nssm.git diff --git a/gui.cpp b/gui.cpp index 97c69a8..84fd4c2 100644 --- a/gui.cpp +++ b/gui.cpp @@ -63,9 +63,9 @@ int install(HWND window) { if (! window) return 1; /* Check parameters in the window */ - char name[STRING_SIZE]; + char name[VALUE_LENGTH]; char exe[EXE_LENGTH]; - char flags[STRING_SIZE]; + char flags[VALUE_LENGTH]; /* Get service name */ if (! GetDlgItemText(window, IDC_NAME, name, sizeof(name))) { @@ -120,7 +120,7 @@ int remove(HWND window) { if (! window) return 1; /* Check parameters in the window */ - char name[STRING_SIZE]; + char name[VALUE_LENGTH]; /* Get service name */ if (! GetDlgItemText(window, IDC_NAME, name, sizeof(name))) { @@ -154,8 +154,8 @@ int remove(HWND window) { void browse(HWND window) { if (! window) return; - unsigned long bufsize = 256; - unsigned long len = bufsize; + size_t bufsize = 256; + size_t len = bufsize; OPENFILENAME ofn; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); @@ -164,18 +164,18 @@ void browse(HWND window) { if (ofn.lpstrFilter) { ZeroMemory((void *) ofn.lpstrFilter, bufsize); char *localised = message_string(NSSM_GUI_BROWSE_FILTER_APPLICATIONS); - _snprintf((char *) ofn.lpstrFilter, bufsize, localised); + _snprintf_s((char *) ofn.lpstrFilter, bufsize, _TRUNCATE, localised); /* "Applications" + NULL + "*.exe" + NULL */ len = strlen(localised) + 1; LocalFree(localised); - _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, "*.exe"); + _snprintf_s((char *) ofn.lpstrFilter + len, bufsize - len, _TRUNCATE, "*.exe"); /* "All files" + NULL + "*.*" + NULL */ len += 6; localised = message_string(NSSM_GUI_BROWSE_FILTER_ALL_FILES); - _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, localised); + _snprintf_s((char *) ofn.lpstrFilter + len, bufsize - len, _TRUNCATE, localised); len += strlen(localised) + 1; LocalFree(localised); - _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, "*.*"); + _snprintf_s((char *) ofn.lpstrFilter + len, bufsize - len, _TRUNCATE, "*.*"); /* Remainder of the buffer is already zeroed */ } ofn.lpstrFile = new char[MAX_PATH];