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

[PATCH] NULL-handling problem with libsvn_subr/config

From: Marcus Comstedt <marcus_at_mc.pp.se>
Date: 2003-02-28 16:23:01 CET

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);
 
- sec_ptr = apr_hash_get (cfg->sections, cfg->tmp_key->data,
- cfg->tmp_key->len);
+ sec_ptr = apr_hash_get (cfg->sections, cfg->tmp_key->data,
+ cfg->tmp_key->len);
+ }
+ else
+ sec_ptr = NULL;
+
   if (sectionp != NULL)
     *sectionp = sec_ptr;
 

---8<--- patch variant 2: make get_server_settings not assume that
         svn_config_find_group can handle NULL ---8<---

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;
+
   if (server_group)
     {
       svn_config_get(cfg, proxy_host, server_group,

---8<---

  // Marcus

---------------------------------------------------------------------
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:26:42 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.