From 1a0ed0d6bb5ffa0991a91cd149d3ecaacb11e59f Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Sat, 15 Mar 2008 20:47:43 +0000 Subject: - 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 --- lib/parse_ini.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/parse_ini.c') 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){ else optend=NULL; } if(optend==NULL) optend=eqptr; +//printf("o1: %c\n", *optptr[optend]); --optend; /* ^[[:space:]]*=foo is a syntax error */ if(optptr==eqptr) die(STATE_UNKNOWN, _("Config file error\n")); @@ -242,6 +243,8 @@ static int add_option(FILE *f, np_arg_list **optlst){ equals=1; cfg_len+=1; } + /* A line with no equal sign isn't valid */ + if(equals==0) die(STATE_UNKNOWN, _("Config file error\n")); /* okay, now we have all the info we need, so we create a new np_arg_list * element and set the argument... @@ -260,8 +263,8 @@ static int add_option(FILE *f, np_arg_list **optlst){ read_pos+=2; } strncpy(&optnew->arg[read_pos], optptr, opt_len); read_pos+=opt_len; - if(equals) optnew->arg[read_pos++]='='; if(value) { + optnew->arg[read_pos++]='='; strncpy(&optnew->arg[read_pos], valptr, val_len); read_pos+=val_len; } optnew->arg[read_pos]='\0'; -- cgit v1.2.3