Cap command size passed to subshell



Hi,

A small fix for the size of the command passed to the subshell pty. 4096
bytes should be enough, right? I believe the compiler should optimize
the double call to strlen(command) away. If not we could introduce an
extra variable here and set it first.

Leonard.

-- 
mount -t life -o ro /dev/dna /genetic/research

src/Changelog:
	* subshell.c (invoke_subshell): Cap size of command written
	to subshell_pty to 4096 chars.
--- src/subshell.c.000	2004-11-07 13:42:53.000000000 +0100
+++ src/subshell.c	2004-11-21 14:49:36.000000000 +0100
@@ -540,8 +540,7 @@ int invoke_subshell (const char *command
     {
 	if (how == QUIETLY)
 	    write (subshell_pty, " ", 1);
-	/* FIXME: if command is long (>8KB ?) we go comma */
-	write (subshell_pty, command, strlen (command));
+	write (subshell_pty, command, strlen(command) > 4096 ? 4096 : strlen(command));
 	write (subshell_pty, "\n", 1);
 	subshell_state = RUNNING_COMMAND;
 	subshell_ready = FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]