Skip to content
Snippets Groups Projects
Commit 044864ae authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

Always use closed string

parent 590821d1
No related branches found
No related tags found
No related merge requests found
......@@ -82,7 +82,7 @@ extern int parse_get_section(lexer_config *acfg, unsigned int *ncfg, char const
extern int parse_key(stack *key, lexer_config *cfg, key_description_t const *list) ;
extern int parse_value(stack *store, lexer_config *kcfg, const int sid, key_description_t const *list, int const kid) ;
extern int parse_list(stack *stk) ;
extern int parse_bracket(stack *store, lexer_config *kcfg, const int sid) ;
extern int parse_bracket(stack *store, const char *line, const int sid) ;
extern int parse_clean_runas(char const *str, int idsec, int idkey) ;
extern int parse_get_value_of_key(stack *store, char const *str, const int sid, key_description_t const *list, const int kid) ;
extern int parse_mandatory(resolve_service_t *res) ;
......
......@@ -62,7 +62,7 @@ static void key_isvalid(const char *line, size_t *o, uint8_t *bracket, int *vp,
return ;
}
int parse_bracket(stack *store, lexer_config *kcfg, const int sid)
int parse_bracket(stack *store, const char *str, const int sid)
{
log_flow() ;
......@@ -72,8 +72,8 @@ int parse_bracket(stack *store, lexer_config *kcfg, const int sid)
lexer_config cfg = LEXER_CONFIG_ZERO ;
cfg.str = kcfg->str + kcfg->cpos ;
cfg.slen = kcfg->slen - kcfg->cpos ;
cfg.str = str ;
cfg.slen = strlen(str) ;
cfg.open = "(";
cfg.olen = 1 ;
cfg.close = ")\n" ;
......
......@@ -25,8 +25,11 @@ int parse_value(stack *store, lexer_config *kcfg, const int sid, key_description
size_t pos = 0 ;
lexer_config vcfg = LEXER_CONFIG_ZERO ;
_alloc_stk_(stk, kcfg->slen - kcfg->cpos) ;
log_trace("parsing value of key: ", *list[kid].name) ;
memcpy(stk.s, kcfg->str + kcfg->cpos, strlen(kcfg->str + kcfg->cpos)) ;
stk.s[strlen(kcfg->str + kcfg->cpos)] = 0 ;
switch(list[kid].expected) {
......@@ -34,18 +37,17 @@ int parse_value(stack *store, lexer_config *kcfg, const int sid, key_description
vcfg = LEXER_CONFIG_QUOTE ;
lexer_reset(&vcfg) ;
vcfg.str = kcfg->str + kcfg->cpos ;
vcfg.str = stk.s ;
vcfg.slen = kcfg->slen - kcfg->cpos ;
if (!lexer(store, &vcfg))
parse_error_return(LOG_EXIT_ZERO, 6, sid, list, kid) ;
kcfg->pos += vcfg.pos - 1 ;
break ;
case EXPECT_BRACKET:
pos = 0 ;
if (!parse_bracket(store, kcfg, sid))
if (!parse_bracket(store, stk.s, sid))
parse_error_return(LOG_EXIT_ZERO, 6, sid, list, kid) ;
kcfg->pos += pos ;
break ;
......@@ -56,7 +58,7 @@ int parse_value(stack *store, lexer_config *kcfg, const int sid, key_description
vcfg = LEXER_CONFIG_INLINE ;
lexer_reset(&vcfg) ;
vcfg.str = kcfg->str + kcfg->cpos ;
vcfg.str = stk.s ;
vcfg.slen = kcfg->slen - kcfg->cpos ;
if (!lexer(store, &vcfg))
parse_error_return(LOG_EXIT_ZERO, 6, sid, list, kid) ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment