apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dwayne C. Litzenberger" <dl...@dlitz.net>
Subject [PATCH] apr_table_overlap doesn't work as advertised
Date Mon, 31 May 2004 00:10:11 GMT
Package: libapr0
Version: 2.0.49-1
Severity: normal
Tags: patch

The function prototype for apr_table_overlap is as follows:

	void apr_table_overlap (apr_table_t *dest, const apr_table_t *src,
				unsigned flags);
  	
According to to the documentation [1], apr_table_overlap is supposed to 
merge the key-value pairs from src and dest into dest.

However, if src and dest are not allocated from the same resource pool, a 
new buffer is allocated for dest, but this buffer is (erroneously) not 
populated with the data from dest.  The result is that the newly-created 
table contains only the data from src, rather than the merged data from 
both src and dest.

I found the problem when trying to set per-directory PythonOption 
directives (both Directory config and .htaccess files) for mod_python.  

The patch below fixes the problem.  On Debian, it can be placed in the 
debian/patches directory of the apache2 source package until upstream fixes 
the problem (I've Cc'd dev@apr.apache.org).

[1] Apache Portable Runtime documentation, "Table and Array Functions"
	http://apr.apache.org/docs/apr/group__apr__tables.html#a31


== BEGIN PATCH =======================================
--- ../apache2-2.0.49/build-tree/apache2/srclib/apr/tables/apr_tables.c	2004-02-13 03:33:52.000000000
-0600
+++ build-tree/apache2/srclib/apr/tables/apr_tables.c	2004-05-30 01:53:07.000000000 -0600
@@ -1197,7 +1197,12 @@
 
     /* copy (extend) a using b's pool */
     if (a->a.pool != p) {
-        make_array_core(&a->a, p, m+n, sizeof(apr_table_entry_t), 0);
+        apr_array_header_t *array_tmp = (apr_array_header_t *)
+            apr_palloc(p, sizeof(apr_array_header_t));
+        make_array_core(array_tmp, p, m + n, sizeof(apr_table_entry_t), 0);
+        apr_array_cat(array_tmp, &a->a);
+        apr_table_clear(a);
+        memcpy(&a->a, array_tmp, sizeof(apr_array_header_t));
     }
 
     apr_table_cat(a, b);
== END PATCH =========================================

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.4.26-1um
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8

Versions of packages libapr0 depends on:
ii  libc6                       2.3.2.ds1-10 GNU C Library: Shared libraries an
ii  libdb4.2                    4.2.52-11    Berkeley v4.2 Database Libraries [
ii  libexpat1                   1.95.6-8     XML parsing C library - runtime li
ii  libpcre3                    4.3-3        Philip Hazel's Perl 5 Compatible R

-- no debconf information

-- 
Dwayne C. Litzenberger <dlitz@dlitz.net>

This message contains an OpenPGP/MIME signature, which can be used to verify 
its authenticity.  If the message itself appears as an attachment, you are 
probably using using a broken mail program, such as Microsoft Outlook Express.

Mime
View raw message