[PATCH 2/3] Patch to new_mini_epn to allow any command line length without breaking on extra trailing or leading whitespace (Ray Bengen)

Thomas Guyot-Sionnest dermoth at aei.ca
Thu Aug 5 13:07:37 CEST 2010


From: Ethan Galstad <egalstad at nagios.org>

---
 Changelog              |    1 +
 THANKS                 |    1 +
 contrib/new_mini_epn.c |   21 ++++++++++++++++-----
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Changelog b/Changelog
index b4283da..54cd941 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ Nagios 3.x Change Log
 3.2.2 - ??/??/2010
 ------------------
 ENHANCEMENTS
+* Patch to new_mini_epn to allow any command line length without breaking on extra trailing or leading whitespace (Ray Bengen)
 * Patch to speed up loading of state retention data (Matthieu Kermagoret)
 * Custom notifications are now suppressed during scheduled downtime (Sven Nierlein)
 
diff --git a/THANKS b/THANKS
index bacf809..b10e20a 100644
--- a/THANKS
+++ b/THANKS
@@ -28,6 +28,7 @@ since 1999.  If I missed your name, let me know.
 * Simon Beale
 * Ben Bell
 * Marlo Bell
+* Ray Bengen
 * Derrick Bennett
 * Chris Bensend
 * Kevin Benton
diff --git a/contrib/new_mini_epn.c b/contrib/new_mini_epn.c
index 4320111..38b24e2 100644
--- a/contrib/new_mini_epn.c
+++ b/contrib/new_mini_epn.c
@@ -217,8 +217,6 @@ void deinit_embedded_perl(void){
 
 int main(int argc, char **argv, char **env) {
 
-	char command_line[128];
-
 	init_embedded_perl();
 										/* Calls Perl to load and construct a new 
 										 * Term::ReadLine object.
@@ -231,13 +229,26 @@ int main(int argc, char **argv, char **env) {
 										 * get_command_line calls Perl to get a scalar from stdin
 										 */
 
-		strncpy(command_line, get_command_line(), 128) ;
-
 										/* Perl Term::ReadLine::readline() method chomps the "\n"
 										 * from the end of the input.
 										 */
-		run_plugin(command_line) ;
+		char *cmd,*end;
+		/* Allow any length command line */
+		cmd = (get_command_line ()) ;
+
+		// Trim leading whitespace
+		while (isspace (*cmd)) cmd++;
+
+		// Trim trailing whitespace
+		end = cmd + strlen (cmd) - 1;
+		while (end > cmd && isspace (*end)) end--;
+
+		// Write new null terminator
+		*(end+1) = 0;
+
+		run_plugin (cmd) ;
 	}
 
 	deinit_embedded_perl();
 }
+
-- 
1.7.1


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm




More information about the Developers mailing list