[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] NULL-handling problem with libsvn_subr/config

From: <cmpilato_at_collab.net>
Date: 2003-02-28 16:32:03 CET

Marcus Comstedt <marcus@mc.pp.se> writes:

> Well, I seem to be in my usual bug-trigging form. :-)
>
> The find_option() function i libsvn_subr/config.c segfaults if it gets
> a NULL cfg parameter. This is bad, since it is used from
> svn_config_enumerate(), which is used from svn_config_find_group(),
> which is supposed to handle a NULL cfg parameter. At least, that's
> what libsvn_ra_dav/session.c thinks. In case svn_config_find_group()
> is _supposed_ to segfault on a NULL cfg, I have an alternative patch
> that fixes libsvn_ra_dav/session.c instead. It is not necessary to
> apply both.
>
>
> ---8<--- patch variant 1: Let svn_config_find_group (and
> svn_config_enumerate and find_option) accept a NULL cfg ---8<---
>
> Index: subversion/libsvn_subr/config.c
> ===================================================================
> --- subversion/libsvn_subr/config.c (revision 5152)
> +++ subversion/libsvn_subr/config.c (working copy)
> @@ -349,12 +349,17 @@
> {
> void *sec_ptr;
>
> - /* Canonicalize the hash key */
> - svn_stringbuf_set (cfg->tmp_key, section);
> - make_hash_key (cfg->tmp_key->data);
> + if (cfg) {
> + /* Canonicalize the hash key */
> + svn_stringbuf_set (cfg->tmp_key, section);
> + make_hash_key (cfg->tmp_key->data);

I'm *sure* you meant:

   if (cfg)
     {
       /* Canonicalize ...

> Index: subversion/libsvn_ra_dav/session.c
> ===================================================================
> --- subversion/libsvn_ra_dav/session.c (revision 5152)
> +++ subversion/libsvn_ra_dav/session.c (working copy)
> @@ -176,8 +176,12 @@
> SVN_CONFIG_OPTION_NEON_DEBUG_MASK, NULL);
> }
>
> - server_group = svn_config_find_group(cfg, requested_host,
> - SVN_CONFIG_SECTION_GROUPS,
> pool);
> + if (cfg)
> + server_group = svn_config_find_group(cfg, requested_host,
> + SVN_CONFIG_SECTION_GROUPS,
> pool);
> + else
> + server_group = NULL;
> +

Check your formatting here, too. SVN_CONFIG_SECTION_GROUPS looks like
it should be shifted one column to the right.

--C-Mike, throwing out good code on formatting violations since his
  conception.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Feb 28 16:33:18 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.