[Nagios-devel] ndoutils - escape custom values

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] ndoutils - escape custom values

Post by Guest »

This is a multi-part message in MIME format.
--------------010007050903060403010401
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi

Here is a patch that escape strings stored in `customvariablestatus` and =
`customvariables`.

I add a ndo2db_save_custom_variables function (I don't like copy/paste) h=
owever this one could be splitted in two (one for each table).

--=20
St=C3=A9phane Urbanovski

--------------010007050903060403010401
Content-Type: text/x-patch;
name="dbhandlers.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="dbhandlers.patch"

--- ndoutils-cvs/src/dbhandlers.c 2007-10-31 19:17:05.000000000 +0100
+++ ndoutils-1.4b7-patched/src/dbhandlers.c 2008-12-18 15:47:48.000000000 +0100
@@ -2381,45 +2381,8 @@
free(es[x]);

/* save custom variables to db */
- mbuf=idi->mbuf[NDO2DB_MBUF_CUSTOMVARIABLE];
- for(x=0;xdbinfo.instance_id
- ,object_id
- ,ts[0]
- ,has_been_modified
- ,(es[0]==NULL)?"":es[0]
- ,(es[1]==NULL)?"":es[1]
- )==-1)
- buf=NULL;
-
- free(es[0]);
- free(es[1]);
-
- if(asprintf(&buf1,"INSERT INTO %s SET %s ON DUPLICATE KEY UPDATE %s"
- ,ndo2db_db_tablenames[NDO2DB_DBTABLE_CUSTOMVARIABLESTATUS]
- ,buf
- ,buf
- )==-1)
- buf1=NULL;
+ result=ndo2db_save_custom_variables(idi,NDO2DB_DBTABLE_CUSTOMVARIABLESTATUS,object_id,ts[0]);

- result=ndo2db_db_query(idi,buf1);
- free(buf);
- free(buf1);
- }

/* free memory */
for(x=0;xmbuf[NDO2DB_MBUF_CUSTOMVARIABLE];
- for(x=0;xdbinfo.instance_id
- ,object_id
- ,ts[0]
- ,has_been_modified
- ,(es[0]==NULL)?"":es[0]
- ,(es[1]==NULL)?"":es[1]
- )==-1)
- buf=NULL;
-
- free(es[0]);
- free(es[1]);
-
- if(asprintf(&buf1,"INSERT INTO %s SET %s ON DUPLICATE KEY UPDATE %s"
- ,ndo2db_db_tablenames[NDO2DB_DBTABLE_CUSTOMVARIABLESTATUS]
- ,buf
- ,buf
- )==-1)
- buf1=NULL;
-
- result=ndo2db_db_query(idi,buf1);
- free(buf);
- free(buf1);
- }
+ result=ndo2db_save_custom_variables(idi,NDO2DB_DBTABLE_CUSTOMVARIABLESTATUS,object_id,ts[0]);

/* free memory */
for(x=0;xmbuf[NDO2DB_MBUF_CUSTOMVARIABLE];
- for(x=0;xdbinfo.instance_id
- ,object_id
- ,ts[0]
- ,has_been_modified
- ,(es[0]==NULL)?"":es[0]
- ,(es[1]==NULL)?"":es[1]
- )==-1)
- buf=NULL;
-
- free(es[0]);
- free(es[1]);
-
- if(asprintf(&buf1,"INSERT INTO %s SET %s ON DUPLICATE KEY UPDATE %s"
- ,ndo2db_db_tablenames[NDO2DB_DBTABLE

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked