Change the limit for the command line length when executing commands to a maximum of 32768 characters (closes #2979697).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4856 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2010-04-25 17:42:12 +00:00
parent 2f63860908
commit 95d82159a8
2 changed files with 11 additions and 7 deletions

View File

@ -3,6 +3,9 @@
* src/build.c, src/dialogs.c, src/msgwindow.c, src/ui_utils.c: * src/build.c, src/dialogs.c, src/msgwindow.c, src/ui_utils.c:
Replace g_vsnprintf() by g_strdup_vprintf() to avoid truncated Replace g_vsnprintf() by g_strdup_vprintf() to avoid truncated
strings in case of reaching the buffer size limit (part of #2979697). strings in case of reaching the buffer size limit (part of #2979697).
* src/win32.c:
Change the limit for the command line length when executing commands
to a maximum of 32768 characters (closes #2979697).
2010-04-22 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2010-04-22 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -57,6 +57,7 @@
#include "editor.h" #include "editor.h"
#define BUFSIZE 4096 #define BUFSIZE 4096
#define CMDSIZE 32768
struct _geany_win32_spawn struct _geany_win32_spawn
{ {
@ -779,9 +780,9 @@ gchar *win32_get_hostname(void)
gboolean win32_spawn(const gchar *dir, gchar **argv, gchar **env, GSpawnFlags flags, gboolean win32_spawn(const gchar *dir, gchar **argv, gchar **env, GSpawnFlags flags,
gchar **std_out, gchar **std_err, gint *exit_status, GError **error) gchar **std_out, gchar **std_err, gint *exit_status, GError **error)
{ {
TCHAR buffer[MAX_PATH]=TEXT(""); TCHAR buffer[CMDSIZE]=TEXT("");
TCHAR cmdline[MAX_PATH] = TEXT(""); TCHAR cmdline[CMDSIZE] = TEXT("");
TCHAR* lpPart[MAX_PATH]={NULL}; TCHAR* lpPart[CMDSIZE]={NULL};
DWORD retval = 0; DWORD retval = 0;
gint argc = 0, i; gint argc = 0, i;
gint cmdpos = 0; gint cmdpos = 0;
@ -808,9 +809,9 @@ gboolean win32_spawn(const gchar *dir, gchar **argv, gchar **env, GSpawnFlags fl
if (flags & G_SPAWN_SEARCH_PATH) if (flags & G_SPAWN_SEARCH_PATH)
{ {
retval = SearchPath(NULL, argv[0], ".exe", MAX_PATH, buffer, lpPart); retval = SearchPath(NULL, argv[0], ".exe", sizeof(buffer), buffer, lpPart);
if (retval > 0) if (retval > 0)
g_snprintf(cmdline, MAX_PATH, "\"%s\"", buffer); g_snprintf(cmdline, sizeof(cmdline), "\"%s\"", buffer);
else else
g_strlcpy(cmdline, argv[0], sizeof(cmdline)); g_strlcpy(cmdline, argv[0], sizeof(cmdline));
cmdpos = 1; cmdpos = 1;
@ -818,7 +819,7 @@ gboolean win32_spawn(const gchar *dir, gchar **argv, gchar **env, GSpawnFlags fl
for (i = cmdpos; i < argc; i++) for (i = cmdpos; i < argc; i++)
{ {
g_snprintf(cmdline, MAX_PATH, "%s %s", cmdline, argv[i]); g_snprintf(cmdline, sizeof(cmdline), "%s %s", cmdline, argv[i]);
/*MessageBox(NULL, cmdline, cmdline, MB_OK);*/ /*MessageBox(NULL, cmdline, cmdline, MB_OK);*/
} }
@ -1010,7 +1011,7 @@ static gboolean CreateChildProcess(geany_win32_spawn *gw_spawn, TCHAR *szCmdline
STARTUPINFOW siStartInfo; STARTUPINFOW siStartInfo;
BOOL bFuncRetn = FALSE; BOOL bFuncRetn = FALSE;
gchar *expandedCmdline; gchar *expandedCmdline;
wchar_t w_commandline[MAX_PATH]; wchar_t w_commandline[CMDSIZE];
wchar_t w_dir[MAX_PATH]; wchar_t w_dir[MAX_PATH];
/* Set up members of the PROCESS_INFORMATION structure. */ /* Set up members of the PROCESS_INFORMATION structure. */