diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-03-15 20:47:43 +0000 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-03-15 20:47:43 +0000 |
commit | 1a0ed0d6bb5ffa0991a91cd149d3ecaacb11e59f (patch) | |
tree | eacf3b2384d2421e58280be627408d6d42711f02 /lib/parse_ini.c | |
parent | 40c123148a9d84218667124a97283f7cb93bfa50 (diff) | |
download | monitoring-plugins-1a0ed0d6bb5ffa0991a91cd149d3ecaacb11e59f.tar.gz |
- Make equal-less parameters illegal
- parameters without argument after '=' are now assumed to be argument-less
- Add a testcase for space in stanza and various argument-less parameters
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1948 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/parse_ini.c')
-rw-r--r-- | lib/parse_ini.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/parse_ini.c b/lib/parse_ini.c index 38bcb39b..ade77e5f 100644 --- a/lib/parse_ini.c +++ b/lib/parse_ini.c | |||
@@ -212,6 +212,7 @@ static int add_option(FILE *f, np_arg_list **optlst){ | |||
212 | else optend=NULL; | 212 | else optend=NULL; |
213 | } | 213 | } |
214 | if(optend==NULL) optend=eqptr; | 214 | if(optend==NULL) optend=eqptr; |
215 | //printf("o1: %c\n", *optptr[optend]); | ||
215 | --optend; | 216 | --optend; |
216 | /* ^[[:space:]]*=foo is a syntax error */ | 217 | /* ^[[:space:]]*=foo is a syntax error */ |
217 | if(optptr==eqptr) die(STATE_UNKNOWN, _("Config file error\n")); | 218 | if(optptr==eqptr) die(STATE_UNKNOWN, _("Config file error\n")); |
@@ -242,6 +243,8 @@ static int add_option(FILE *f, np_arg_list **optlst){ | |||
242 | equals=1; | 243 | equals=1; |
243 | cfg_len+=1; | 244 | cfg_len+=1; |
244 | } | 245 | } |
246 | /* A line with no equal sign isn't valid */ | ||
247 | if(equals==0) die(STATE_UNKNOWN, _("Config file error\n")); | ||
245 | 248 | ||
246 | /* okay, now we have all the info we need, so we create a new np_arg_list | 249 | /* okay, now we have all the info we need, so we create a new np_arg_list |
247 | * element and set the argument... | 250 | * element and set the argument... |
@@ -260,8 +263,8 @@ static int add_option(FILE *f, np_arg_list **optlst){ | |||
260 | read_pos+=2; | 263 | read_pos+=2; |
261 | } | 264 | } |
262 | strncpy(&optnew->arg[read_pos], optptr, opt_len); read_pos+=opt_len; | 265 | strncpy(&optnew->arg[read_pos], optptr, opt_len); read_pos+=opt_len; |
263 | if(equals) optnew->arg[read_pos++]='='; | ||
264 | if(value) { | 266 | if(value) { |
267 | optnew->arg[read_pos++]='='; | ||
265 | strncpy(&optnew->arg[read_pos], valptr, val_len); read_pos+=val_len; | 268 | strncpy(&optnew->arg[read_pos], valptr, val_len); read_pos+=val_len; |
266 | } | 269 | } |
267 | optnew->arg[read_pos]='\0'; | 270 | optnew->arg[read_pos]='\0'; |