Config file parser for lists

Russ Allbery rra at stanford.edu
Sat Mar 28 11:49:15 UTC 2009


Julien ÉLIE <julien at trigofacile.com> writes:

> Something is tampering at the allocated memory during innconf_parse.

Yes.  The cast here was a symptom of the problem:

>            *list = (vector_ptr == NULL) ? vector_new() : (struct vector *) vector_ptr;

It's not as clear as it should be, but in include/inn/confparse.h see:

/* Free all space allocated by the tree rooted at config_group.  One normally
   never wants to do this.  WARNING: This includes the storage allocated for
   all strings returned by config_param_string and config_param_list for any
   configuration groups in this tree. */
void config_free(struct config_group *);

innconf_parse frees the parse tree in innconf_read.  That's why all the
settings of strings use xstrdup.  You similarly have to do a deep copy of
any vectors returned by the parse if you want their contents to survive.
(Or we could keep a copy of the parse tree in memory and just keep
references to it, but other parts of INN want to free chunks of innconf,
so this was easier.)

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>

    Please send questions to the list rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.



More information about the inn-workers mailing list