Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1E7F1F9B1 for ; Sun, 31 Mar 2013 10:03:30 +0000 (UTC) Received: (qmail 53802 invoked by uid 500); 31 Mar 2013 10:03:29 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 53653 invoked by uid 500); 31 Mar 2013 10:03:27 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 53598 invoked by uid 99); 31 Mar 2013 10:03:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 Mar 2013 10:03:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 Mar 2013 10:03:22 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2F5BF23888CD; Sun, 31 Mar 2013 10:03:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1462907 - /subversion/trunk/subversion/libsvn_fs_fs/caching.c Date: Sun, 31 Mar 2013 10:03:01 -0000 To: commits@subversion.apache.org From: stefan2@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130331100301.2F5BF23888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: stefan2 Date: Sun Mar 31 10:03:00 2013 New Revision: 1462907 URL: http://svn.apache.org/r1462907 Log: When constructing the key prefix that we use for key space separation in FSFS caches, make sure that the ":" delimiter is not found in any of the key parts. Otherwise, we might be able to construct the same prefix using a different combination of elements. Normalizing those parts that potentially need it must not limit their value space, however, as this would again allow for different element values to result in the same key prefix. * subversion/libsvn_fs_fs/caching.c (normalize_namespace): new utility function (read_config, svn_fs_fs__initialize_caches): normalize elements of the key prefix Modified: subversion/trunk/subversion/libsvn_fs_fs/caching.c Modified: subversion/trunk/subversion/libsvn_fs_fs/caching.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/caching.c?rev=1462907&r1=1462906&r2=1462907&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_fs_fs/caching.c (original) +++ subversion/trunk/subversion/libsvn_fs_fs/caching.c Sun Mar 31 10:03:00 2013 @@ -38,6 +38,33 @@ #include "private/svn_debug.h" #include "private/svn_subr_private.h" +/* Take the ORIGINAL string and replace all occurrences of ":" without + * limiting the key space. Allocate the result in POOL. + */ +static const char * +normalize_key_part(const char *original, + apr_pool_t *pool) +{ + apr_size_t i; + apr_size_t len = strlen(original); + svn_stringbuf_t *normalized = svn_stringbuf_create_ensure(len, pool); + + for (i = 0; i < len; ++i) + { + char c = original[i]; + switch (c) + { + case ':': svn_stringbuf_appendbytes(normalized, "%_", 2); + break; + case '%': svn_stringbuf_appendbytes(normalized, "%%", 2); + break; + default : svn_stringbuf_appendbyte(normalized, c); + } + } + + return normalized->data; +} + /* Return a memcache in *MEMCACHE_P for FS if it's configured to use memcached, or NULL otherwise. Also, sets *FAIL_STOP to a boolean indicating whether cache errors should be returned to the caller or @@ -69,12 +96,16 @@ read_config(svn_memcache_t **memcache_p, * share / compete for the same cache memory but keys will not match * across namespaces and, thus, cached data will not be shared between * namespaces. + * + * Since the namespace will be concatenated with other elements to form + * the complete key prefix, we must make sure that the resulting string + * is unique and cannot be created by any other combination of elements. */ *cache_namespace - = apr_pstrdup(fs->pool, - svn_hash__get_cstring(fs->config, - SVN_FS_CONFIG_FSFS_CACHE_NS, - "")); + = normalize_key_part(svn_hash__get_cstring(fs->config, + SVN_FS_CONFIG_FSFS_CACHE_NS, + ""), + pool); /* don't cache text deltas by default. * Once we reconstructed the fulltexts from the deltas, @@ -313,7 +344,8 @@ svn_fs_fs__initialize_caches(svn_fs_t *f fs_fs_data_t *ffd = fs->fsap_data; const char *prefix = apr_pstrcat(pool, "fsfs:", fs->uuid, - "/", fs->path, ":", + "/", normalize_key_part(fs->path, pool), + ":", (char *)NULL); svn_memcache_t *memcache; svn_membuffer_t *membuffer;