[Nagiosplug-checkins] SF.net SVN: nagiosplug: [1971] nagiosplug/trunk/lib

dermoth at users.sourceforge.net dermoth at users.sourceforge.net
Tue Apr 1 11:31:27 CEST 2008


Revision: 1971
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1971&view=rev
Author:   dermoth
Date:     2008-04-01 02:31:27 -0700 (Tue, 01 Apr 2008)

Log Message:
-----------
np_extra_opts now retain pointers from argv so that plugins can still overwrite sensitive options

Modified Paths:
--------------
    nagiosplug/trunk/lib/extra_opts.c
    nagiosplug/trunk/lib/extra_opts.h

Modified: nagiosplug/trunk/lib/extra_opts.c
===================================================================
--- nagiosplug/trunk/lib/extra_opts.c	2008-03-31 07:07:39 UTC (rev 1970)
+++ nagiosplug/trunk/lib/extra_opts.c	2008-04-01 09:31:27 UTC (rev 1971)
@@ -122,7 +122,7 @@
 	if(argv_new==NULL) die(STATE_UNKNOWN, _("malloc() failed!\n"));
 
 	/* starting with program name */
-	argv_new[0]=strdup(argv[0]);
+	argv_new[0]=argv[0];
 	argc_new=1;
 	/* then parsed ini opts (frying them up in the same run) */
 	while(extra_args){
@@ -132,7 +132,7 @@
 		free(ea1);
 	}
 	/* finally the rest of the argv array */
-	for (i=1; i<*argc; i++)	argv_new[argc_new++]=strdup(argv[i]);
+	for (i=1; i<*argc; i++)	argv_new[argc_new++]=argv[i];
 	*argc=argc_new;
 	/* and terminate. */
 	argv_new[argc_new]=NULL;

Modified: nagiosplug/trunk/lib/extra_opts.h
===================================================================
--- nagiosplug/trunk/lib/extra_opts.h	2008-03-31 07:07:39 UTC (rev 1970)
+++ nagiosplug/trunk/lib/extra_opts.h	2008-04-01 09:31:27 UTC (rev 1971)
@@ -11,8 +11,8 @@
  * ini-procesed arguments always come first (in the ord of --extra-opts
  * arguments). If no --extra-opts arguments are provided or returned nothing
  * it returns **argv otherwise the new array is returned. --extra-opts are
- * always removed from **argv and the new array and all its elements can be
- * freed with free();
+ * always removed from **argv. The original pointers from **argv are kept in
+ * the new array to preserve ability to overwrite arguments in processlist.
  */
 char **np_extra_opts(int *argc, char **argv, const char *plugin_name);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list