[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: config parser bug
On Wed, 2004-05-19 at 09:55, John Leach wrote:
> Hi,
>
> I came across a bug in the config parser. It assumes every line in the
> config has a space in it and treats everything before it as the key and
> everything after it as the value. If there is no space in a line, the
> value is null and segfaults on a strlen later on.
>
> This patch just checks for a null val and returns an error.
Thanks, I commited the following patch.
--- src/args.c (revision 478)
+++ src/args.c (working copy)
@@ -461,7 +461,7 @@
char *r;
struct arg *tmp;
char *sval;
- int ret=0;
+ int ret=-1;
if ( arg_strcpy(kbuf, sizeof(kbuf), key, klen) < klen )
return -1;
@@ -509,7 +509,8 @@
int arg_dispatch(struct arg *a, const char *key, const char *val, void
*priv)
{
- return arg_found(a, key, strlen(key), val, strlen(val), priv);
+ return arg_found(a, key, strlen(key),
+ val, val ? strlen(val) : 0, priv);
}
/* Determine what kind of quote character this is */
--
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/scaramanga.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D