~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/libsvn_subr/cache-inprocess.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
190
190
{
191
191
  struct cache_entry *entry = apr_hash_get(cache->hash, key, cache->klen);
192
192
 
193
 
  *buffer = NULL;
194
193
  if (entry)
195
194
    {
196
195
      SVN_ERR(move_page_to_front(cache, entry->page));
197
196
 
198
197
      /* duplicate the buffer entry */
199
198
      *buffer = apr_palloc(result_pool, entry->size);
200
 
      memcpy(*buffer, entry->value, entry->size);
 
199
      if (entry->size)
 
200
        memcpy(*buffer, entry->value, entry->size);
201
201
 
202
202
      *size = entry->size;
203
203
    }
 
204
  else
 
205
    {
 
206
      *buffer = NULL;
 
207
      *size = 0;
 
208
    }
204
209
 
205
210
  return SVN_NO_ERROR;
206
211
}
213
218
                    apr_pool_t *result_pool)
214
219
{
215
220
  inprocess_cache_t *cache = cache_void;
216
 
  char* buffer = NULL;
217
 
  apr_size_t size;
 
221
 
 
222
  if (key)
 
223
    {
 
224
      char* buffer;
 
225
      apr_size_t size;
 
226
 
 
227
      SVN_MUTEX__WITH_LOCK(cache->mutex,
 
228
                           inprocess_cache_get_internal(&buffer,
 
229
                                                        &size,
 
230
                                                        cache,
 
231
                                                        key,
 
232
                                                        result_pool));
 
233
      /* deserialize the buffer content. Usually, this will directly
 
234
         modify the buffer content directly. */
 
235
      *found = (buffer != NULL);
 
236
      if (!buffer || !size)
 
237
        *value_p = NULL;
 
238
      else
 
239
        return cache->deserialize_func(value_p, buffer, size, result_pool);
 
240
    }
 
241
  else
 
242
    {
 
243
      *value_p = NULL;
 
244
      *found = FALSE;
 
245
    }
 
246
 
 
247
  return SVN_NO_ERROR;
 
248
}
 
249
 
 
250
static svn_error_t *
 
251
inprocess_cache_has_key_internal(svn_boolean_t *found,
 
252
                                 inprocess_cache_t *cache,
 
253
                                 const void *key,
 
254
                                 apr_pool_t *scratch_pool)
 
255
{
 
256
  *found = apr_hash_get(cache->hash, key, cache->klen) != NULL;
 
257
 
 
258
  return SVN_NO_ERROR;
 
259
}
 
260
 
 
261
static svn_error_t *
 
262
inprocess_cache_has_key(svn_boolean_t *found,
 
263
                        void *cache_void,
 
264
                        const void *key,
 
265
                        apr_pool_t *scratch_pool)
 
266
{
 
267
  inprocess_cache_t *cache = cache_void;
218
268
 
219
269
  if (key)
220
270
    SVN_MUTEX__WITH_LOCK(cache->mutex,
221
 
                         inprocess_cache_get_internal(&buffer,
222
 
                                                      &size,
223
 
                                                      cache,
224
 
                                                      key,
225
 
                                                      result_pool));
 
271
                         inprocess_cache_has_key_internal(found,
 
272
                                                          cache,
 
273
                                                          key,
 
274
                                                          scratch_pool));
 
275
  else
 
276
    *found = FALSE;
226
277
 
227
 
  /* deserialize the buffer content. Usually, this will directly
228
 
     modify the buffer content directly.
229
 
   */
230
 
  *value_p = NULL;
231
 
  *found = buffer != NULL;
232
 
  return buffer && size
233
 
    ? cache->deserialize_func(value_p, buffer, size, result_pool)
234
 
    : SVN_NO_ERROR;
 
278
  return SVN_NO_ERROR;
235
279
}
236
280
 
237
281
/* Removes PAGE from the LRU list, removes all of its entries from
592
636
 
593
637
static svn_cache__vtable_t inprocess_cache_vtable = {
594
638
  inprocess_cache_get,
 
639
  inprocess_cache_has_key,
595
640
  inprocess_cache_set,
596
641
  inprocess_cache_iter,
597
642
  inprocess_cache_is_cachable,
642
687
 
643
688
  wrapper->vtable = &inprocess_cache_vtable;
644
689
  wrapper->cache_internal = cache;
 
690
  wrapper->pretend_empty = !!getenv("SVN_X_DOES_NOT_MARK_THE_SPOT");
645
691
 
646
692
  *cache_p = wrapper;
647
693
  return SVN_NO_ERROR;