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

« back to all changes in this revision

Viewing changes to subversion/include/private/svn_subr_private.h

  • 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:
26
26
 
27
27
#include "svn_types.h"
28
28
#include "svn_io.h"
29
 
#include "svn_version.h"
 
29
#include "svn_config.h"
30
30
 
31
31
 
32
32
#ifdef __cplusplus
95
95
                     apr_size_t maxsize,
96
96
                     apr_pool_t *result_pool);
97
97
 
 
98
/* Create a spill buffer, with extra parameters.  */
 
99
svn_spillbuf_t *
 
100
svn_spillbuf__create_extended(apr_size_t blocksize,
 
101
                              apr_size_t maxsize,
 
102
                              svn_boolean_t delete_on_close,
 
103
                              svn_boolean_t spill_all_contents,
 
104
                              const char* dirpath,
 
105
                              apr_pool_t *result_pool);
98
106
 
99
107
/* Determine how much content is stored in the spill buffer.  */
100
108
svn_filesize_t
101
109
svn_spillbuf__get_size(const svn_spillbuf_t *buf);
102
110
 
 
111
/* Determine how much content the spill buffer is caching in memory.  */
 
112
svn_filesize_t
 
113
svn_spillbuf__get_memory_size(const svn_spillbuf_t *buf);
 
114
 
 
115
/* Retrieve the name of the spill file. The returned value can be NULL
 
116
   if the file has not been created yet. */
 
117
const char *
 
118
svn_spillbuf__get_filename(const svn_spillbuf_t *buf);
 
119
 
 
120
/* Retrieve the handle of the spill file. The returned value can be
 
121
   NULL if the file has not been created yet. */
 
122
apr_file_t *
 
123
svn_spillbuf__get_file(const svn_spillbuf_t *buf);
103
124
 
104
125
/* Write some data into the spill buffer.  */
105
126
svn_error_t *
153
174
typedef struct svn_spillbuf_reader_t svn_spillbuf_reader_t;
154
175
 
155
176
 
156
 
/* Create a spill-buffer and a reader for it.  */
 
177
/* Create a spill-buffer and a reader for it, using the same arguments as
 
178
   svn_spillbuf__create().  */
157
179
svn_spillbuf_reader_t *
158
180
svn_spillbuf__reader_create(apr_size_t blocksize,
159
181
                            apr_size_t maxsize,
160
182
                            apr_pool_t *result_pool);
161
183
 
162
 
 
163
184
/* Read @a len bytes from @a reader into @a data. The number of bytes
164
185
   actually read is stored in @a amt. If the content is exhausted, then
165
186
   @a amt is set to zero. It will always be non-zero if the spill-buffer
191
212
                           apr_pool_t *scratch_pool);
192
213
 
193
214
 
194
 
/* Return a stream built on top of a spillbuf, using the same arguments as
195
 
   svn_spillbuf__create().  This stream can be used for reading and writing,
196
 
   but implements the same basic sematics of a spillbuf for the underlying
197
 
   storage. */
 
215
/* Return a stream built on top of a spillbuf.
 
216
 
 
217
   This stream can be used for reading and writing, but implements the
 
218
   same basic semantics of a spillbuf for the underlying storage. */
198
219
svn_stream_t *
199
 
svn_stream__from_spillbuf(apr_size_t blocksize,
200
 
                          apr_size_t maxsize,
 
220
svn_stream__from_spillbuf(svn_spillbuf_t *buf,
201
221
                          apr_pool_t *result_pool);
202
222
 
203
223
/** @} */
204
224
 
 
225
/*----------------------------------------------------*/
 
226
 
 
227
/**
 
228
 * @defgroup svn_checksum_private Checksumming helper APIs
 
229
 * @{
 
230
 */
 
231
 
205
232
/**
206
233
 * Internal function for creating a MD5 checksum from a binary digest.
207
234
 *
221
248
svn_checksum__from_digest_sha1(const unsigned char *digest,
222
249
                               apr_pool_t *result_pool);
223
250
 
 
251
/**
 
252
 * Internal function for creating a 32 bit FNV-1a checksum from a binary
 
253
 * digest.
 
254
 *
 
255
 * @since New in 1.9
 
256
 */
 
257
svn_checksum_t *
 
258
svn_checksum__from_digest_fnv1a_32(const unsigned char *digest,
 
259
                                   apr_pool_t *result_pool);
 
260
 
 
261
/**
 
262
 * Internal function for creating a modified 32 bit FNV-1a checksum from
 
263
 * a binary digest.
 
264
 *
 
265
 * @since New in 1.9
 
266
 */
 
267
svn_checksum_t *
 
268
svn_checksum__from_digest_fnv1a_32x4(const unsigned char *digest,
 
269
                                     apr_pool_t *result_pool);
 
270
 
 
271
 
 
272
/**
 
273
 * Return a stream that calculates a checksum of type @a kind over all
 
274
 * data written to the @a inner_stream.  When the returned stream gets
 
275
 * closed, write the checksum to @a *checksum.
 
276
 * Allocate the result in @a pool.
 
277
 *
 
278
 * @note The stream returned only supports #svn_stream_write and
 
279
 * #svn_stream_close.
 
280
 */
 
281
svn_stream_t *
 
282
svn_checksum__wrap_write_stream(svn_checksum_t **checksum,
 
283
                                svn_stream_t *inner_stream,
 
284
                                svn_checksum_kind_t kind,
 
285
                                apr_pool_t *pool);
 
286
 
 
287
/**
 
288
 * Return a stream that calculates a 32 bit modified FNV-1a checksum
 
289
 * over all data written to the @a inner_stream and writes the digest
 
290
 * to @a *digest when the returned stream gets closed.
 
291
 * Allocate the stream in @a pool.
 
292
 */
 
293
svn_stream_t *
 
294
svn_checksum__wrap_write_stream_fnv1a_32x4(apr_uint32_t *digest,
 
295
                                           svn_stream_t *inner_stream,
 
296
                                           apr_pool_t *pool);
 
297
 
 
298
/**
 
299
 * Return a 32 bit FNV-1a checksum for the first @a len bytes in @a input.
 
300
 *
 
301
 * @since New in 1.9
 
302
 */
 
303
apr_uint32_t
 
304
svn__fnv1a_32(const void *input, apr_size_t len);
 
305
 
 
306
/**
 
307
 * Return a 32 bit modified FNV-1a checksum for the first @a len bytes in
 
308
 * @a input.
 
309
 *
 
310
 * @note This is a proprietary checksumming algorithm based FNV-1a with
 
311
 *       approximately the same strength.  It is up to 4 times faster
 
312
 *       than plain FNV-1a for longer data blocks.
 
313
 *
 
314
 * @since New in 1.9
 
315
 */
 
316
apr_uint32_t
 
317
svn__fnv1a_32x4(const void *input, apr_size_t len);
 
318
 
 
319
/** @} */
 
320
 
224
321
 
225
322
/**
226
323
 * @defgroup svn_hash_support Hash table serialization support
285
382
 
286
383
/** @} */
287
384
 
 
385
/**
 
386
 * @defgroup svn_hash_read Reading serialized hash tables
 
387
 * @{
 
388
 */
 
389
 
 
390
/** Struct that represents a key value pair read from a serialized hash
 
391
 * representation.  There are special cases that can also be represented:
 
392
 * a #NULL @a key signifies the end of the hash, a #NULL @a val for non-
 
393
 * NULL keys is only possible in incremental mode describes a deletion.
 
394
 *
 
395
 * @since New in 1.9.
 
396
 */
 
397
typedef struct svn_hash__entry_t
 
398
{
 
399
  /** 0-terminated Key.  #NULL if this contains no data at all because we
 
400
   * encountered the end of the hash. */
 
401
  char *key;
 
402
 
 
403
  /** Length of @a key.  Must be 0 if @a key is #NULL. */
 
404
  apr_size_t keylen;
 
405
 
 
406
  /** 0-terminated value stored with the key.  If this is #NULL for a
 
407
   * non-NULL @a key, then this means that the key shall be removed from
 
408
   * the hash (only used in incremental mode).  Must be #NULL if @a key is
 
409
   * #NULL. */
 
410
  char *val;
 
411
 
 
412
  /** Length of @a val.  Must be 0 if @a val is #NULL. */
 
413
  apr_size_t vallen;
 
414
} svn_hash__entry_t;
 
415
 
 
416
/** Reads a single key-value pair from @a stream and returns it in the
 
417
 * caller-provided @a *entry (members don't need to be pre-initialized).
 
418
 * @a pool is used to allocate members of @a *entry and for tempoaries.
 
419
 *
 
420
 * @see #svn_hash_read2 for more details.
 
421
 *
 
422
 * @since New in 1.9.
 
423
 */
 
424
svn_error_t *
 
425
svn_hash__read_entry(svn_hash__entry_t *entry,
 
426
                     svn_stream_t *stream,
 
427
                     const char *terminator,
 
428
                     svn_boolean_t incremental,
 
429
                     apr_pool_t *pool);
 
430
 
 
431
/** @} */
 
432
 
288
433
/** @} */
289
434
 
290
435
 
332
477
                      int minor,
333
478
                      int patch);
334
479
 
335
 
/** Like svn_ver_check_list(), but with a @a comparator parameter.
336
 
 * Private backport of svn_ver_check_list2() from trunk.
337
 
 */
338
 
svn_error_t *
339
 
svn_ver__check_list2(const svn_version_t *my_version,
340
 
                     const svn_version_checklist_t *checklist,
341
 
                     svn_boolean_t (*comparator)(const svn_version_t *,
342
 
                                                 const svn_version_t *));
343
 
 
344
 
/** To minimize merge churn in callers, alias the trunk name privately. */
345
 
#define svn_ver_check_list2 svn_ver__check_list2
 
480
/** @} */
 
481
 
 
482
/**
 
483
 * @defgroup svn_compress Data (de-)compression API
 
484
 * @{
 
485
 */
 
486
 
 
487
/* This is at least as big as the largest size of an integer that
 
488
   svn__encode_uint() can generate; it is sufficient for creating buffers
 
489
   for it to write into.  This assumes that integers are at most 64 bits,
 
490
   and so 10 bytes (with 7 bits of information each) are sufficient to
 
491
   represent them. */
 
492
#define SVN__MAX_ENCODED_UINT_LEN 10
 
493
 
 
494
/* Compression method parameters for svn__encode_uint. */
 
495
 
 
496
/* No compression (but a length prefix will still be added to the buffer) */
 
497
#define SVN__COMPRESSION_NONE         0
 
498
 
 
499
/* Fastest, least effective compression method & level provided by zlib. */
 
500
#define SVN__COMPRESSION_ZLIB_MIN     1
 
501
 
 
502
/* Default compression method & level provided by zlib. */
 
503
#define SVN__COMPRESSION_ZLIB_DEFAULT 5
 
504
 
 
505
/* Slowest, best compression method & level provided by zlib. */
 
506
#define SVN__COMPRESSION_ZLIB_MAX     9
 
507
 
 
508
/* Encode VAL into the buffer P using the variable-length 7b/8b unsigned
 
509
   integer format.  Return the incremented value of P after the
 
510
   encoded bytes have been written.  P must point to a buffer of size
 
511
   at least SVN__MAX_ENCODED_UINT_LEN.
 
512
 
 
513
   This encoding uses the high bit of each byte as a continuation bit
 
514
   and the other seven bits as data bits.  High-order data bits are
 
515
   encoded first, followed by lower-order bits, so the value can be
 
516
   reconstructed by concatenating the data bits from left to right and
 
517
   interpreting the result as a binary number.  Examples (brackets
 
518
   denote byte boundaries, spaces are for clarity only):
 
519
 
 
520
           1 encodes as [0 0000001]
 
521
          33 encodes as [0 0100001]
 
522
         129 encodes as [1 0000001] [0 0000001]
 
523
        2000 encodes as [1 0001111] [0 1010000]
 
524
*/
 
525
unsigned char *
 
526
svn__encode_uint(unsigned char *p, apr_uint64_t val);
 
527
 
 
528
/* Decode an unsigned 7b/8b-encoded integer into *VAL and return a pointer
 
529
   to the byte after the integer.  The bytes to be decoded live in the
 
530
   range [P..END-1].  If these bytes do not contain a whole encoded
 
531
   integer, return NULL; in this case *VAL is undefined.
 
532
 
 
533
   See the comment for svn__encode_uint() earlier in this file for more
 
534
   detail on the encoding format.  */
 
535
const unsigned char *
 
536
svn__decode_uint(apr_uint64_t *val,
 
537
                 const unsigned char *p,
 
538
                 const unsigned char *end);
 
539
 
 
540
/* Get the data from IN, compress it according to the specified
 
541
 * COMPRESSION_METHOD and write the result to OUT.
 
542
 * SVN__COMPRESSION_NONE is valid for COMPRESSION_METHOD.
 
543
 */
 
544
svn_error_t *
 
545
svn__compress(svn_stringbuf_t *in,
 
546
              svn_stringbuf_t *out,
 
547
              int compression_method);
 
548
 
 
549
/* Get the compressed data from IN, decompress it and write the result to
 
550
 * OUT.  Return an error if the decompressed size is larger than LIMIT.
 
551
 */
 
552
svn_error_t *
 
553
svn__decompress(svn_stringbuf_t *in,
 
554
                svn_stringbuf_t *out,
 
555
                apr_size_t limit);
 
556
 
 
557
/** @} */
 
558
 
 
559
/**
 
560
 * @defgroup svn_root_pools Recycle-able root pools API
 
561
 * @{
 
562
 */
 
563
 
 
564
/* Opaque thread-safe container for unused / recylcleable root pools.
 
565
 *
 
566
 * Recyling root pools (actually, their allocators) circumvents a
 
567
 * scalability bottleneck in the OS memory management when multi-threaded
 
568
 * applications frequently create and destroy allocators.
 
569
 */
 
570
typedef struct svn_root_pools__t svn_root_pools__t;
 
571
 
 
572
/* Create a new root pools container and return it in *POOLS.
 
573
 */
 
574
svn_error_t *
 
575
svn_root_pools__create(svn_root_pools__t **pools);
 
576
 
 
577
/* Return a currently unused pool from POOLS.  If POOLS is empty, create a
 
578
 * new root pool and return that.  The pool returned is not thread-safe.
 
579
 */
 
580
apr_pool_t *
 
581
svn_root_pools__acquire_pool(svn_root_pools__t *pools);
 
582
 
 
583
/* Clear and release the given root POOL and put it back into POOLS.
 
584
 * If that fails, destroy POOL.
 
585
 */
 
586
void
 
587
svn_root_pools__release_pool(apr_pool_t *pool,
 
588
                             svn_root_pools__t *pools);
 
589
 
 
590
/** @} */
 
591
 
 
592
/**
 
593
 * @defgroup svn_config_private Private configuration handling API
 
594
 * @{
 
595
 */
 
596
 
 
597
/* Future attempts to modify CFG will trigger an assertion. */
 
598
void
 
599
svn_config__set_read_only(svn_config_t *cfg,
 
600
                          apr_pool_t *scratch_pool);
 
601
 
 
602
/* Return TRUE, if CFG cannot be modified. */
 
603
svn_boolean_t
 
604
svn_config__is_read_only(svn_config_t *cfg);
 
605
 
 
606
/* Return TRUE, if OPTION in SECTION in CFG exists and does not require
 
607
 * further expansion (due to either containing no placeholders or already
 
608
 * having been expanded). */
 
609
svn_boolean_t
 
610
svn_config__is_expanded(svn_config_t *cfg,
 
611
                        const char *section,
 
612
                        const char *option);
 
613
 
 
614
/* Return a shallow copy of SCR in POOL.  If SRC is read-only, different
 
615
 * shallow copies may be used from different threads.
 
616
 *
 
617
 * Any single r/o svn_config_t or shallow copy is not thread-safe because
 
618
 * it contains shared buffers for tempoary data.
 
619
 */
 
620
svn_config_t *
 
621
svn_config__shallow_copy(svn_config_t *src,
 
622
                         apr_pool_t *pool);
 
623
 
 
624
/* Add / replace SECTION in TARGET with the same section from SOURCE by
 
625
 * simply adding a reference to it.  If TARGET is read-only, the sections
 
626
 * list in target gets duplicated before the modification.
 
627
 *
 
628
 * This is an API tailored for use by the svn_repos__authz_pool_t API to
 
629
 * prevent breach of encapsulation.
 
630
 */
 
631
void
 
632
svn_config__shallow_replace_section(svn_config_t *target,
 
633
                                    svn_config_t *source,
 
634
                                    const char *section);
 
635
 
 
636
/* Allocate *CFG_HASH and populate it with default, empty,
 
637
 * svn_config_t for the configuration categories (@c
 
638
 * SVN_CONFIG_CATEGORY_SERVERS, @c SVN_CONFIG_CATEGORY_CONFIG, etc.).
 
639
 * This returns a hash equivalent to svn_config_get_config when the
 
640
 * config files are empty.
 
641
 */
 
642
svn_error_t *
 
643
svn_config__get_default_config(apr_hash_t **cfg_hash,
 
644
                               apr_pool_t *pool);
 
645
 
 
646
/** @} */
 
647
 
 
648
 
 
649
/**
 
650
 * @defgroup svn_bit_array Packed bit array handling API
 
651
 * @{
 
652
 */
 
653
 
 
654
/* This opaque data struct is an alternative to an INT->VOID hash.
 
655
 *
 
656
 * Technically, it is an automatically growing packed bit array.
 
657
 * All indexes not previously set are implicitly 0 and setting it will
 
658
 * grow the array as needed.
 
659
 */
 
660
typedef struct svn_bit_array__t svn_bit_array__t;
 
661
 
 
662
/* Return a new bit array allocated in POOL.  MAX is a mere hint for
 
663
 * the initial size of the array in bits.
 
664
 */
 
665
svn_bit_array__t *
 
666
svn_bit_array__create(apr_size_t max,
 
667
                      apr_pool_t *pool);
 
668
 
 
669
/* Set bit at index IDX in ARRAY to VALUE.  If necessary, grow the
 
670
 * underlying data buffer, i.e. any IDX is valid unless we run OOM.
 
671
 */
 
672
void
 
673
svn_bit_array__set(svn_bit_array__t *array,
 
674
                   apr_size_t idx,
 
675
                   svn_boolean_t value);
 
676
 
 
677
/* Get the bit value at index IDX in ARRAY.  Bits not previously accessed
 
678
 * are implicitly 0 (or FALSE).  That implies IDX can never be out-of-range.
 
679
 */
 
680
svn_boolean_t
 
681
svn_bit_array__get(svn_bit_array__t *array,
 
682
                   apr_size_t idx);
 
683
 
 
684
/* Return the global pool used by the DSO loader, this may be NULL if
 
685
   no DSOs have been loaded. */
 
686
apr_pool_t *
 
687
svn_dso__pool(void);
346
688
 
347
689
/** @} */
348
690