Config file parser for lists
Julien ÉLIE
julien at trigofacile.com
Sat Mar 28 11:28:47 UTC 2009
Hi Russ,
>> parameter: [ string string ... ]
>>
>> Has anyone written the parser for such lists? (so that I could use it
>> for instance to parse overview fields)
>
> Yeah, it should be there already and work. config_param_list will hand
> you a vector with the members of the list when you ask for a key that was
> set that way. I just never ended up using it for inn.conf, but the
> library code was all written and the test suite verifies it.
OK, that's great.
However, I do not manage to make it work.
If I do not put "extraoverview" in inn.conf, it is properly handled:
% ./innconfval -p | head -3
$domain = '';
$enableoverview = 'true';
@extraoverview = ( 'xref' );
But if I put "extraoverview: [ one two three four ]" in inn.conf, I get:
% ./innconfval -p | head -3
$domain = '';
$enableoverview = 'true';
@extraoverview = ( '`' 'Ð' '(e' '8' );
Something is tampering at the allocated memory during innconf_parse.
Code is attached.
Index: include/inn/innconf.h
===================================================================
--- include/inn/innconf.h (révision 8385)
+++ include/inn/innconf.h (copie de travail)
@@ -59,6 +59,8 @@
/* Article Storage */
long cnfscheckfudgesize; /* Additional CNFS integrity checking */
bool enableoverview; /* Store overview info for articles? */
+ struct vector
+ *extraoverview; /* Extra overview fields for LIST OVERVIEW.FMT */
bool groupbaseexpiry; /* Do expiry by newsgroup? */
bool mergetogroups; /* Refile articles from to.* into to */
bool nfswriter; /* Use NFS writer functionality */
Maybe CONF_LIST is wrong?
#define CONF_LIST(conf, offset) (struct vector **)(void *)((char *) (conf) + (offset))
Or parsing?
const struct vector *vector_ptr;
struct vector **list;
case TYPE_LIST:
/* vector_ptr contains the value taken from inn.conf or the
* default value from config_table; *list points to the inn.conf
* structure in memory for this parameter. */
if (!config_param_list(group, config_table[i].name, &vector_ptr))
vector_ptr = config_table[i].defaults.list;
list = CONF_LIST(config, config_table[i].location);
*list = (vector_ptr == NULL) ? vector_new() : (struct vector *) vector_ptr;
break;
config_param_list (group=0x8054048, key=0x804eb19 "extraoverview", result=0xbfdd2ef4) at confparse.c:1557
(gdb) print result
$5 = (const struct vector **) 0xbfdd2ef4
(gdb) print **result
$7 = {count = 4, allocated = 4, strings = 0x8054118}
(gdb) print result->strings
$8 = (char **) 0x8054118
(gdb) print result->strings[0]
$9 = 0x8054108 "one"
(gdb) print result->strings[1]
$13 = 0x8054128 "two"
At the end of innconf_parse:
(gdb) print config->extraoverview->strings
$45 = (char **) 0x8054118
(gdb) print config->extraoverview->strings[1]
$46 = 0x8054128 "two"
But then:
Breakpoint 4, innconf_dump (file=0xb7f863a0, quoting=INNCONF_QUOTE_NONE) at innconf.c:855
(gdb) print *innconf->extraoverview
$50 = {count = 134562120, allocated = 4, strings = 0x8054118}
(gdb) print innconf->extraoverview->strings[1]
$51 = 0x8054128 "Ð\005\b"
I think the vector struct has been freed (at the end of innconf_parse?)
or tampered by something else (count is not normal).
How can I prevent that from happening?
Thanks,
--
Julien ÉLIE
« La vie n'est qu'un tissu de coups de poignard qu'il faut savoir boire goutte à goutte. »
-------------- next part --------------
A non-text attachment was scrubbed...
Name: innconf.c
Type: application/octet-stream
Size: 35989 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/inn-workers/attachments/20090328/5d86bd11/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: innconf.diff
Type: application/octet-stream
Size: 11318 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/inn-workers/attachments/20090328/5d86bd11/attachment-0001.obj>
More information about the inn-workers
mailing list