You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2016/04/29 20:38:56 UTC
svn commit: r1741682 [16/26] - in /subversion/branches/authzperf: ./ build/
build/ac-macros/ build/generator/ contrib/server-side/svncutter/ notes/
notes/api-errata/1.9/ notes/move-tracking/ subversion/
subversion/bindings/ctypes-python/ subversion/bin...
Modified: subversion/branches/authzperf/subversion/libsvn_subr/cache-membuffer.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/cache-membuffer.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/cache-membuffer.c Fri Apr 29 18:38:53 2016
@@ -147,6 +147,10 @@
#endif
/* For more efficient copy operations, let's align all data items properly.
+ * Since we can't portably align pointers, this is rather the item size
+ * granularity which ensures *relative* alignment within the cache - still
+ * giving us decent copy speeds on most machines.
+ *
* Must be a power of 2.
*/
#define ITEM_ALIGNMENT 16
@@ -353,7 +357,8 @@ prefix_pool_get_internal(apr_uint32_t *p
}
bytes_needed = prefix_len + 1 + OVERHEAD;
- if (prefix_pool->bytes_used + bytes_needed > prefix_pool->values_max)
+ assert(prefix_pool->bytes_max >= prefix_pool->bytes_used);
+ if (prefix_pool->bytes_max - prefix_pool->bytes_used < bytes_needed)
{
*prefix_idx = NO_INDEX;
return SVN_NO_ERROR;
@@ -813,10 +818,6 @@ struct svn_membuffer_t
*/
#define ALIGN_VALUE(value) (((value) + ITEM_ALIGNMENT-1) & -ITEM_ALIGNMENT)
-/* Align POINTER value to the next ITEM_ALIGNMENT boundary.
- */
-#define ALIGN_POINTER(pointer) ((void*)ALIGN_VALUE((apr_size_t)(char*)(pointer)))
-
/* If locking is supported for CACHE, acquire a read lock for it.
*/
static svn_error_t *
@@ -1630,7 +1631,7 @@ ensure_data_insertable_l2(svn_membuffer_
/* accumulated size of the entries that have been removed to make
* room for the new one.
*/
- apr_size_t moved_size = 0;
+ apr_uint64_t moved_size = 0;
/* count the number of entries that got moved. A single large entry
* being moved is not enough to reject an insertion.
@@ -1664,15 +1665,15 @@ ensure_data_insertable_l2(svn_membuffer_
/* leave function as soon as the insertion window is large enough
*/
- if (end >= to_fit_in->size + cache->l2.current_data)
+ if (end - cache->l2.current_data >= to_fit_in->size)
return TRUE;
/* Don't be too eager to cache data. If a lot of data has been moved
* around, the current item has probably a relatively low priority.
- * We must also limit the effort spent here (if even in case of faulty
+ * We must also limit the effort spent here (even in case of faulty
* heuristics). Therefore, give up after some time.
*/
- if (moved_size > 4 * to_fit_in->size && moved_count > 7)
+ if (moved_size / 4 > to_fit_in->size && moved_count > 7)
return FALSE;
/* if the net worth (in weighted hits) of items removed is already
@@ -1789,7 +1790,7 @@ ensure_data_insertable_l1(svn_membuffer_
/* leave function as soon as the insertion window is large enough
*/
- if (end >= size + cache->l1.current_data)
+ if (end - cache->l1.current_data >= size)
return TRUE;
/* Enlarge the insertion window
@@ -1826,28 +1827,6 @@ ensure_data_insertable_l1(svn_membuffer_
* right answer. */
}
-/* Mimic apr_pcalloc in APR_POOL_DEBUG mode, i.e. handle failed allocations
- * (e.g. OOM) properly: Allocate at least SIZE bytes from POOL and zero
- * the content of the allocated memory if ZERO has been set. Return NULL
- * upon failed allocations.
- *
- * Also, satisfy our buffer alignment needs for performance reasons.
- */
-static void* secure_aligned_alloc(apr_pool_t *pool,
- apr_size_t size,
- svn_boolean_t zero)
-{
- void* memory = apr_palloc(pool, size + ITEM_ALIGNMENT);
- if (memory != NULL)
- {
- memory = ALIGN_POINTER(memory);
- if (zero)
- memset(memory, 0, size);
- }
-
- return memory;
-}
-
svn_error_t *
svn_cache__membuffer_cache_create(svn_membuffer_t **cache,
apr_size_t total_size,
@@ -2016,10 +1995,11 @@ svn_cache__membuffer_cache_create(svn_me
c[seg].l2.last = NO_INDEX;
c[seg].l2.next = NO_INDEX;
c[seg].l2.start_offset = c[seg].l1.size;
- c[seg].l2.size = data_size - c[seg].l1.size;
+ c[seg].l2.size = ALIGN_VALUE(data_size) - c[seg].l1.size;
c[seg].l2.current_data = c[seg].l2.start_offset;
- c[seg].data = secure_aligned_alloc(pool, (apr_size_t)data_size, FALSE);
+ /* This cast is safe because DATA_SIZE <= MAX_SEGMENT_SIZE. */
+ c[seg].data = apr_palloc(pool, (apr_size_t)ALIGN_VALUE(data_size));
c[seg].data_used = 0;
c[seg].max_entry_size = max_entry_size;
@@ -2213,14 +2193,24 @@ membuffer_cache_set_internal(svn_membuff
apr_pool_t *scratch_pool)
{
cache_level_t *level;
- apr_size_t size = item_size + to_find->entry_key.key_len;
+ apr_size_t size;
/* first, look for a previous entry for the given key */
entry_t *entry = find_entry(cache, group_index, to_find, FALSE);
+ /* Quick check make sure arithmetics will work further down the road. */
+ size = item_size + to_find->entry_key.key_len;
+ if (size < item_size)
+ {
+ /* Arithmetic overflow, so combination of serialized ITEM and KEY
+ * cannot not fit into the cache. Setting BUFFER to NULL will cause
+ * the removal of any entry if that exists without writing new data. */
+ buffer = NULL;
+ }
+
/* if there is an old version of that entry and the new data fits into
* the old spot, just re-use that space. */
- if (entry && ALIGN_VALUE(entry->size) >= size && buffer)
+ if (entry && buffer && ALIGN_VALUE(entry->size) >= size)
{
/* Careful! We need to cast SIZE to the full width of CACHE->DATA_USED
* lest we run into trouble with 32 bit underflow *not* treated as a
@@ -2398,7 +2388,7 @@ membuffer_cache_get_internal(svn_membuff
}
size = ALIGN_VALUE(entry->size) - entry->key.key_len;
- *buffer = ALIGN_POINTER(apr_palloc(result_pool, size + ITEM_ALIGNMENT-1));
+ *buffer = apr_palloc(result_pool, size);
memcpy(*buffer, cache->data + entry->offset + entry->key.key_len, size);
#ifdef SVN_DEBUG_CACHE_MEMBUFFER
@@ -2678,9 +2668,11 @@ membuffer_cache_set_partial_internal(svn
if (item_data != orig_data)
{
/* Remove the old entry and try to make space for the new one.
+ * Note that the key has already been stored in the past, i.e.
+ * it is shorter than the MAX_ENTRY_SIZE.
*/
drop_entry(cache, entry);
- if ( (cache->max_entry_size >= item_size + key_len)
+ if ( (cache->max_entry_size - key_len >= item_size)
&& ensure_data_insertable_l1(cache, item_size + key_len))
{
/* Write the new entry.
@@ -3371,6 +3363,11 @@ svn_cache__create_membuffer_cache(svn_ca
prefix_orig_len = strlen(prefix) + 1;
prefix_len = ALIGN_VALUE(prefix_orig_len);
+ /* Paranoia check to ensure pointer arithmetics work as expected. */
+ if (prefix_orig_len >= SVN_MAX_OBJECT_SIZE)
+ return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
+ _("Prefix too long"));
+
/* Construct the folded prefix key. */
SVN_ERR(svn_checksum(&checksum,
svn_checksum_md5,
Modified: subversion/branches/authzperf/subversion/libsvn_subr/checksum.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/checksum.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/checksum.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/checksum.c Fri Apr 29 18:38:53 2016
@@ -86,6 +86,7 @@ static const char *ckind_str[] = {
"$sha1$",
"$fnv1$",
"$fnvm$",
+ /* ### svn_checksum_deserialize() assumes all these have the same strlen() */
};
/* Returns the digest size of it's argument. */
Modified: subversion/branches/authzperf/subversion/libsvn_subr/cmdline.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/cmdline.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/cmdline.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/cmdline.c Fri Apr 29 18:38:53 2016
@@ -42,6 +42,7 @@
#include <apr_general.h> /* for apr_initialize/apr_terminate */
#include <apr_strings.h> /* for apr_snprintf */
#include <apr_pools.h>
+#include <apr_signal.h>
#include "svn_cmdline.h"
#include "svn_ctype.h"
@@ -1171,6 +1172,36 @@ svn_cmdline__print_xml_prop_hash(svn_str
}
svn_boolean_t
+svn_cmdline__stdin_is_a_terminal(void)
+{
+#ifdef WIN32
+ return (_isatty(STDIN_FILENO) != 0);
+#else
+ return (isatty(STDIN_FILENO) != 0);
+#endif
+}
+
+svn_boolean_t
+svn_cmdline__stdout_is_a_terminal(void)
+{
+#ifdef WIN32
+ return (_isatty(STDOUT_FILENO) != 0);
+#else
+ return (isatty(STDOUT_FILENO) != 0);
+#endif
+}
+
+svn_boolean_t
+svn_cmdline__stderr_is_a_terminal(void)
+{
+#ifdef WIN32
+ return (_isatty(STDERR_FILENO) != 0);
+#else
+ return (isatty(STDERR_FILENO) != 0);
+#endif
+}
+
+svn_boolean_t
svn_cmdline__be_interactive(svn_boolean_t non_interactive,
svn_boolean_t force_interactive)
{
@@ -1576,3 +1607,99 @@ svn_cmdline__parse_trust_options(
return SVN_NO_ERROR;
}
+
+/* Flags to see if we've been cancelled by the client or not. */
+static volatile sig_atomic_t cancelled = FALSE;
+static volatile sig_atomic_t signum_cancelled = 0;
+
+/* The signals we handle. */
+static int signal_map [] = {
+ SIGINT
+#ifdef SIGBREAK
+ /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
+ , SIGBREAK
+#endif
+#ifdef SIGHUP
+ , SIGHUP
+#endif
+#ifdef SIGTERM
+ , SIGTERM
+#endif
+};
+
+/* A signal handler to support cancellation. */
+static void
+signal_handler(int signum)
+{
+ int i;
+
+ apr_signal(signum, SIG_IGN);
+ cancelled = TRUE;
+ for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
+ if (signal_map[i] == signum)
+ {
+ signum_cancelled = i + 1;
+ break;
+ }
+}
+
+/* An svn_cancel_func_t callback. */
+static svn_error_t *
+check_cancel(void *baton)
+{
+ /* Cancel baton should be always NULL in command line client. */
+ SVN_ERR_ASSERT(baton == NULL);
+ if (cancelled)
+ return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
+ else
+ return SVN_NO_ERROR;
+}
+
+svn_cancel_func_t
+svn_cmdline__setup_cancellation_handler(void)
+{
+ int i;
+
+ for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
+ apr_signal(signal_map[i], signal_handler);
+
+#ifdef SIGPIPE
+ /* Disable SIGPIPE generation for the platforms that have it. */
+ apr_signal(SIGPIPE, SIG_IGN);
+#endif
+
+#ifdef SIGXFSZ
+ /* Disable SIGXFSZ generation for the platforms that have it, otherwise
+ * working with large files when compiled against an APR that doesn't have
+ * large file support will crash the program, which is uncool. */
+ apr_signal(SIGXFSZ, SIG_IGN);
+#endif
+
+ return check_cancel;
+}
+
+void
+svn_cmdline__disable_cancellation_handler(void)
+{
+ int i;
+
+ for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
+ apr_signal(signal_map[i], SIG_DFL);
+}
+
+void
+svn_cmdline__cancellation_exit(void)
+{
+ int signum = 0;
+
+ if (cancelled && signum_cancelled)
+ signum = signal_map[signum_cancelled - 1];
+ if (signum)
+ {
+#ifndef WIN32
+ apr_signal(signum, SIG_DFL);
+ /* No APR support for getpid() so cannot use apr_proc_kill(). */
+ kill(getpid(), signum);
+#endif
+ }
+}
Modified: subversion/branches/authzperf/subversion/libsvn_subr/compress.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/compress.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/compress.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/compress.c Fri Apr 29 18:38:53 2016
@@ -82,6 +82,17 @@ svn__encode_uint(unsigned char *p, apr_u
return p;
}
+unsigned char *
+svn__encode_int(unsigned char *p, apr_int64_t val)
+{
+ apr_uint64_t value = val;
+ value = value & APR_UINT64_C(0x8000000000000000)
+ ? APR_UINT64_MAX - (2 * value)
+ : 2 * value;
+
+ return svn__encode_uint(p, value);
+}
+
const unsigned char *
svn__decode_uint(apr_uint64_t *val,
const unsigned char *p,
@@ -89,7 +100,7 @@ svn__decode_uint(apr_uint64_t *val,
{
apr_uint64_t temp = 0;
- if (p + SVN__MAX_ENCODED_UINT_LEN < end)
+ if (end - p > SVN__MAX_ENCODED_UINT_LEN)
end = p + SVN__MAX_ENCODED_UINT_LEN;
/* Decode bytes until we're done. */
@@ -111,6 +122,22 @@ svn__decode_uint(apr_uint64_t *val,
return NULL;
}
+const unsigned char *
+svn__decode_int(apr_int64_t *val,
+ const unsigned char *p,
+ const unsigned char *end)
+{
+ apr_uint64_t value;
+ const unsigned char *result = svn__decode_uint(&value, p, end);
+
+ value = value & 1
+ ? (APR_UINT64_MAX - value / 2)
+ : value / 2;
+ *val = (apr_int64_t)value;
+
+ return result;
+}
+
/* If IN is a string that is >= MIN_COMPRESS_SIZE and the COMPRESSION_LEVEL
is not SVN_DELTA_COMPRESSION_LEVEL_NONE, zlib compress it and places the
result in OUT, with an integer prepended specifying the original size.
Modified: subversion/branches/authzperf/subversion/libsvn_subr/config.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/config.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/config.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/config.c Fri Apr 29 18:38:53 2016
@@ -379,22 +379,14 @@ for_each_option(svn_config_t *cfg, void
sec_ndx != NULL;
sec_ndx = apr_hash_next(sec_ndx))
{
- void *sec_ptr;
- cfg_section_t *sec;
+ cfg_section_t *sec = apr_hash_this_val(sec_ndx);
apr_hash_index_t *opt_ndx;
- apr_hash_this(sec_ndx, NULL, NULL, &sec_ptr);
- sec = sec_ptr;
-
for (opt_ndx = apr_hash_first(pool, sec->options);
opt_ndx != NULL;
opt_ndx = apr_hash_next(opt_ndx))
{
- void *opt_ptr;
- cfg_option_t *opt;
-
- apr_hash_this(opt_ndx, NULL, NULL, &opt_ptr);
- opt = opt_ptr;
+ cfg_option_t *opt = apr_hash_this_val(opt_ndx);
if (callback(baton, sec, opt))
return;
@@ -1051,11 +1043,8 @@ svn_config_enumerate_sections2(svn_confi
sec_ndx != NULL;
sec_ndx = apr_hash_next(sec_ndx))
{
- void *sec_ptr;
- cfg_section_t *sec;
+ cfg_section_t *sec = apr_hash_this_val(sec_ndx);
- apr_hash_this(sec_ndx, NULL, NULL, &sec_ptr);
- sec = sec_ptr;
++count;
svn_pool_clear(iteration_pool);
if (!callback(sec->name, baton, iteration_pool))
@@ -1087,13 +1076,9 @@ svn_config_enumerate(svn_config_t *cfg,
opt_ndx != NULL;
opt_ndx = apr_hash_next(opt_ndx))
{
- void *opt_ptr;
- cfg_option_t *opt;
+ cfg_option_t *opt = apr_hash_this_val(opt_ndx);
const char *temp_value;
- apr_hash_this(opt_ndx, NULL, NULL, &opt_ptr);
- opt = opt_ptr;
-
++count;
make_string_from_option(&temp_value, cfg, sec, opt, NULL);
if (!callback(opt->name, temp_value, baton))
@@ -1125,13 +1110,9 @@ svn_config_enumerate2(svn_config_t *cfg,
opt_ndx != NULL;
opt_ndx = apr_hash_next(opt_ndx))
{
- void *opt_ptr;
- cfg_option_t *opt;
+ cfg_option_t *opt = apr_hash_this_val(opt_ndx);
const char *temp_value;
- apr_hash_this(opt_ndx, NULL, NULL, &opt_ptr);
- opt = opt_ptr;
-
++count;
make_string_from_option(&temp_value, cfg, sec, opt, NULL);
svn_pool_clear(iteration_pool);
Modified: subversion/branches/authzperf/subversion/libsvn_subr/config_file.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/config_file.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/config_file.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/config_file.c Fri Apr 29 18:38:53 2016
@@ -82,6 +82,9 @@ typedef struct parse_context_t
char parser_buffer[SVN__STREAM_CHUNK_SIZE]; /* Larger than most config files */
size_t buffer_pos; /* Current position within parser_buffer */
size_t buffer_size; /* parser_buffer contains this many bytes */
+
+ /* Non-zero if we hit EOF on the stream. */
+ svn_boolean_t hit_stream_eof;
} parse_context_t;
@@ -212,11 +215,15 @@ parser_getc(parse_context_t *ctx, int *c
}
else
{
- ctx->buffer_pos = 0;
- ctx->buffer_size = sizeof(ctx->parser_buffer);
+ if (!ctx->hit_stream_eof)
+ {
+ ctx->buffer_pos = 0;
+ ctx->buffer_size = sizeof(ctx->parser_buffer);
- SVN_ERR(svn_stream_read_full(ctx->stream, ctx->parser_buffer,
- &(ctx->buffer_size)));
+ SVN_ERR(svn_stream_read_full(ctx->stream, ctx->parser_buffer,
+ &(ctx->buffer_size)));
+ ctx->hit_stream_eof = (ctx->buffer_size != sizeof(ctx->parser_buffer));
+ }
if (ctx->buffer_pos < ctx->buffer_size)
{
@@ -386,8 +393,10 @@ skip_bom(parse_context_t *ctx)
* of the BOM characters into the parse_context_t buffer. This can
* safely be assumed as long as we only try to use skip_bom() at the
* start of the stream and the buffer is longer than 3 characters. */
- SVN_ERR_ASSERT(ctx->buffer_size > ctx->buffer_pos + 1);
- if (buf[ctx->buffer_pos] == 0xBB && buf[ctx->buffer_pos + 1] == 0xBF)
+ SVN_ERR_ASSERT(ctx->buffer_size > ctx->buffer_pos + 1 ||
+ ctx->hit_stream_eof);
+ if (ctx->buffer_size > ctx->buffer_pos + 1 &&
+ buf[ctx->buffer_pos] == 0xBB && buf[ctx->buffer_pos + 1] == 0xBF)
ctx->buffer_pos += 2;
else
SVN_ERR(parser_ungetc(ctx, ch));
@@ -769,6 +778,7 @@ svn_config__parse_stream(svn_stream_t *s
ctx->line_read = svn_stringbuf_create_empty(scratch_pool);
ctx->buffer_pos = 0;
ctx->buffer_size = 0;
+ ctx->hit_stream_eof = FALSE;
SVN_ERR(skip_bom(ctx));
Modified: subversion/branches/authzperf/subversion/libsvn_subr/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/deprecated.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/deprecated.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/deprecated.c Fri Apr 29 18:38:53 2016
@@ -46,6 +46,7 @@
#include "svn_utf.h"
#include "svn_xml.h"
#include "svn_auth.h"
+#include "svn_base64.h"
#include "opt.h"
#include "auth.h"
@@ -1209,6 +1210,16 @@ svn_stream_checksummed(svn_stream_t *str
return s;
}
+svn_error_t *
+svn_string_from_stream(svn_string_t **result,
+ svn_stream_t *stream,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ return svn_error_trace(svn_string_from_stream2(result, stream, 0,
+ result_pool));
+}
+
/*** From path.c ***/
const char *
@@ -1564,3 +1575,10 @@ svn_cmdline_create_auth_baton(svn_auth_b
cancel_baton,
pool));
}
+
+/*** From base64.c ***/
+svn_stream_t *
+svn_base64_encode(svn_stream_t *output, apr_pool_t *pool)
+{
+ return svn_base64_encode2(output, TRUE, pool);
+}
Modified: subversion/branches/authzperf/subversion/libsvn_subr/eol.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/eol.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/eol.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/eol.c Fri Apr 29 18:38:53 2016
@@ -33,43 +33,32 @@
char *
svn_eol__find_eol_start(char *buf, apr_size_t len)
{
-#if !SVN_UNALIGNED_ACCESS_IS_OK
-
- /* On some systems, we need to make sure that BUF is properly aligned
- * for chunky data access. This overhead is still justified because
- * only lines tend to be tens of chars long.
- */
- for (; (len > 0) && ((apr_uintptr_t)buf) & (sizeof(apr_uintptr_t)-1)
- ; ++buf, --len)
- {
- if (*buf == '\n' || *buf == '\r')
- return buf;
- }
-
-#endif
+#if SVN_UNALIGNED_ACCESS_IS_OK
/* Scan the input one machine word at a time. */
for (; len > sizeof(apr_uintptr_t)
; buf += sizeof(apr_uintptr_t), len -= sizeof(apr_uintptr_t))
- {
- /* This is a variant of the well-known strlen test: */
- apr_uintptr_t chunk = *(const apr_uintptr_t *)buf;
-
- /* A byte in SVN__R_TEST is \0, iff it was \r in *BUF.
- * Similarly, SVN__N_TEST is an indicator for \n. */
- apr_uintptr_t r_test = chunk ^ SVN__R_MASK;
- apr_uintptr_t n_test = chunk ^ SVN__N_MASK;
-
- /* A byte in SVN__R_TEST can only be < 0x80, iff it has been \0 before
- * (i.e. \r in *BUF). Ditto for SVN__N_TEST. */
- r_test |= (r_test & SVN__LOWER_7BITS_SET) + SVN__LOWER_7BITS_SET;
- n_test |= (n_test & SVN__LOWER_7BITS_SET) + SVN__LOWER_7BITS_SET;
-
- /* Check whether at least one of the words contains a byte <0x80
- * (if one is detected, there was a \r or \n in CHUNK). */
- if ((r_test & n_test & SVN__BIT_7_SET) != SVN__BIT_7_SET)
- break;
- }
+ {
+ /* This is a variant of the well-known strlen test: */
+ apr_uintptr_t chunk = *(const apr_uintptr_t *)buf;
+
+ /* A byte in SVN__R_TEST is \0, iff it was \r in *BUF.
+ * Similarly, SVN__N_TEST is an indicator for \n. */
+ apr_uintptr_t r_test = chunk ^ SVN__R_MASK;
+ apr_uintptr_t n_test = chunk ^ SVN__N_MASK;
+
+ /* A byte in SVN__R_TEST can only be < 0x80, iff it has been \0 before
+ * (i.e. \r in *BUF). Ditto for SVN__N_TEST. */
+ r_test |= (r_test & SVN__LOWER_7BITS_SET) + SVN__LOWER_7BITS_SET;
+ n_test |= (n_test & SVN__LOWER_7BITS_SET) + SVN__LOWER_7BITS_SET;
+
+ /* Check whether at least one of the words contains a byte <0x80
+ * (if one is detected, there was a \r or \n in CHUNK). */
+ if ((r_test & n_test & SVN__BIT_7_SET) != SVN__BIT_7_SET)
+ break;
+ }
+
+#endif
/* The remaining odd bytes will be examined the naive way: */
for (; len > 0; ++buf, --len)
Modified: subversion/branches/authzperf/subversion/libsvn_subr/gpg_agent.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/gpg_agent.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/gpg_agent.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/gpg_agent.c Fri Apr 29 18:38:53 2016
@@ -103,6 +103,40 @@ escape_blanks(char *str)
return str;
}
+#define is_hex(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'A' && (c) <= 'F'))
+#define hex_to_int(c) ((c) < '9' ? (c) - '0' : (c) - 'A' + 10)
+
+/* Modify STR in-place. '%', CR and LF are always percent escaped,
+ other characters may be percent escaped, always using uppercase
+ hex, see https://www.gnupg.org/documentation/manuals/assuan.pdf */
+static char *
+unescape_assuan(char *str)
+{
+ char *s = str;
+
+ while (s[0])
+ {
+ if (s[0] == '%' && is_hex(s[1]) && is_hex(s[2]))
+ {
+ char *s2 = s;
+ char val = hex_to_int(s[1]) * 16 + hex_to_int(s[2]);
+
+ s2[0] = val;
+ ++s2;
+
+ while (s2[2])
+ {
+ s2[0] = s2[2];
+ ++s2;
+ }
+ s2[0] = '\0';
+ }
+ ++s;
+ }
+
+ return str;
+}
+
/* Generate the string CACHE_ID_P based on the REALMSTRING allocated in
* RESULT_POOL using SCRATCH_POOL for temporary allocations. This is similar
* to other password caching mechanisms. */
@@ -378,7 +412,7 @@ password_get_gpg_agent(svn_boolean_t *do
apr_pool_t *pool)
{
int sd;
- const char *p = NULL;
+ char *p = NULL;
char *ep = NULL;
char *buffer;
const char *request = NULL;
@@ -451,7 +485,7 @@ password_get_gpg_agent(svn_boolean_t *do
if (ep != NULL)
*ep = '\0';
- *password = p;
+ *password = unescape_assuan(p);
*done = TRUE;
return SVN_NO_ERROR;
Modified: subversion/branches/authzperf/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/io.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/io.c Fri Apr 29 18:38:53 2016
@@ -1531,14 +1531,17 @@ reown_file(const char *path,
}
/* Determine what the PERMS for a new file should be by looking at the
- permissions of a temporary file that we create.
+ permissions of a temporary file that we create in DIRECTORY.
+ DIRECTORY can be NULL in which case the system temporary dir is used.
Unfortunately, umask() as defined in POSIX provides no thread-safe way
to get at the current value of the umask, so what we're doing here is
the only way we have to determine which combination of write bits
(User/Group/World) should be set by default.
Make temporary allocations in SCRATCH_POOL. */
static svn_error_t *
-get_default_file_perms(apr_fileperms_t *perms, apr_pool_t *scratch_pool)
+get_default_file_perms(apr_fileperms_t *perms,
+ const char *directory,
+ apr_pool_t *scratch_pool)
{
/* the default permissions as read from the temp folder */
static apr_fileperms_t default_perms = 0;
@@ -1565,12 +1568,18 @@ get_default_file_perms(apr_fileperms_t *
Using svn_io_open_uniquely_named() here because other tempfile
creation functions tweak the permission bits of files they create.
+
+ Note that APR pool structures are allocated as the first item
+ in their first memory page (with e.g. 4kB granularity), i.e. the
+ lower bits tend to be identical between pool instances. That is
+ particularly true for the MMAPed allocator.
*/
randomish = ((apr_uint32_t)(apr_uintptr_t)scratch_pool
+ + (apr_uint32_t)((apr_uintptr_t)scratch_pool / 4096)
+ (apr_uint32_t)apr_time_now());
fname_base = apr_psprintf(scratch_pool, "svn-%08x", randomish);
- SVN_ERR(svn_io_open_uniquely_named(&fd, &fname, NULL, fname_base,
+ SVN_ERR(svn_io_open_uniquely_named(&fd, &fname, directory, fname_base,
NULL, svn_io_file_del_none,
scratch_pool, scratch_pool));
err = svn_io_file_info_get(&finfo, APR_FINFO_PROT, fd, scratch_pool);
@@ -1588,16 +1597,19 @@ get_default_file_perms(apr_fileperms_t *
}
/* OR together permission bits of the file FD and the default permissions
- of a file as determined by get_default_file_perms(). Do temporary
+ of a file as determined by get_default_file_perms(). DIRECTORY is used
+ to create temporary files, DIRECTORY can be NULL. Do temporary
allocations in SCRATCH_POOL. */
static svn_error_t *
-merge_default_file_perms(apr_file_t *fd, apr_fileperms_t *perms,
+merge_default_file_perms(apr_file_t *fd,
+ apr_fileperms_t *perms,
+ const char *directory,
apr_pool_t *scratch_pool)
{
apr_finfo_t finfo;
apr_fileperms_t default_perms;
- SVN_ERR(get_default_file_perms(&default_perms, scratch_pool));
+ SVN_ERR(get_default_file_perms(&default_perms, directory, scratch_pool));
SVN_ERR(svn_io_file_info_get(&finfo, APR_FINFO_PROT, fd, scratch_pool));
/* Glom the perms together. */
@@ -3751,6 +3763,22 @@ svn_io_file_size_get(svn_filesize_t *fil
}
svn_error_t *
+svn_io_file_get_offset(apr_off_t *offset_p,
+ apr_file_t *file,
+ apr_pool_t *pool)
+{
+ apr_off_t offset;
+
+ /* Note that, for buffered files, one (possibly surprising) side-effect
+ of this call is to flush any unwritten data to disk. */
+ offset = 0;
+ SVN_ERR(svn_io_file_seek(file, APR_CUR, &offset, pool));
+ *offset_p = offset;
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
svn_io_file_read(apr_file_t *file, void *buf,
apr_size_t *nbytes, apr_pool_t *pool)
{
@@ -5280,7 +5308,8 @@ svn_io_open_unique_file3(apr_file_t **fi
{
svn_error_t *err;
- SVN_ERR(merge_default_file_perms(tempfile, &perms, scratch_pool));
+ SVN_ERR(merge_default_file_perms(tempfile, &perms, dirpath,
+ scratch_pool));
err = file_perms_set2(tempfile, perms, scratch_pool);
if (err)
{
@@ -5360,8 +5389,7 @@ svn_io_file_readline(apr_file_t *file,
apr_off_t pos;
/* Check for "\r\n" by peeking at the next byte. */
- pos = 0;
- SVN_ERR(svn_io_file_seek(file, APR_CUR, &pos, scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&pos, file, scratch_pool));
SVN_ERR(svn_io_file_read_full2(file, &c, sizeof(c), &numbytes,
&found_eof, scratch_pool));
if (numbytes == 1 && c == '\n')
Modified: subversion/branches/authzperf/subversion/libsvn_subr/opt.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/opt.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/opt.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/opt.c Fri Apr 29 18:38:53 2016
@@ -350,41 +350,50 @@ print_command_info2(const svn_opt_subcom
return SVN_NO_ERROR;
}
-void
-svn_opt_print_generic_help2(const char *header,
- const svn_opt_subcommand_desc2_t *cmd_table,
- const apr_getopt_option_t *opt_table,
- const char *footer,
- apr_pool_t *pool, FILE *stream)
+/* The body for svn_opt_print_generic_help2() function with standard error
+ * handling semantic. Handling of errors implemented at caller side. */
+static svn_error_t *
+print_generic_help_body(const char *header,
+ const svn_opt_subcommand_desc2_t *cmd_table,
+ const apr_getopt_option_t *opt_table,
+ const char *footer,
+ apr_pool_t *pool, FILE *stream)
{
int i = 0;
- svn_error_t *err;
if (header)
- if ((err = svn_cmdline_fputs(header, stream, pool)))
- goto print_error;
+ SVN_ERR(svn_cmdline_fputs(header, stream, pool));
while (cmd_table[i].name)
{
- if ((err = svn_cmdline_fputs(" ", stream, pool))
- || (err = print_command_info2(cmd_table + i, opt_table,
- NULL, FALSE,
- pool, stream))
- || (err = svn_cmdline_fputs("\n", stream, pool)))
- goto print_error;
+ SVN_ERR(svn_cmdline_fputs(" ", stream, pool));
+ SVN_ERR(print_command_info2(cmd_table + i, opt_table,
+ NULL, FALSE,
+ pool, stream));
+ SVN_ERR(svn_cmdline_fputs("\n", stream, pool));
i++;
}
- if ((err = svn_cmdline_fputs("\n", stream, pool)))
- goto print_error;
+ SVN_ERR(svn_cmdline_fputs("\n", stream, pool));
if (footer)
- if ((err = svn_cmdline_fputs(footer, stream, pool)))
- goto print_error;
+ SVN_ERR(svn_cmdline_fputs(footer, stream, pool));
+
+ return SVN_NO_ERROR;
+}
+
+void
+svn_opt_print_generic_help2(const char *header,
+ const svn_opt_subcommand_desc2_t *cmd_table,
+ const apr_getopt_option_t *opt_table,
+ const char *footer,
+ apr_pool_t *pool, FILE *stream)
+{
+ svn_error_t *err;
- return;
+ err = print_generic_help_body(header, cmd_table, opt_table, footer, pool,
+ stream);
- print_error:
/* Issue #3014:
* Don't print anything on broken pipes. The pipe was likely
* closed by the process at the other end. We expect that
@@ -392,7 +401,7 @@ svn_opt_print_generic_help2(const char *
*
* ### This assumes that there is only one error in a chain for
* ### SVN_ERR_IO_PIPE_WRITE_ERROR. See svn_cmdline_fputs(). */
- if (err->apr_err != SVN_ERR_IO_PIPE_WRITE_ERROR)
+ if (err && err->apr_err != SVN_ERR_IO_PIPE_WRITE_ERROR)
svn_handle_error2(err, stderr, FALSE, "svn: ");
svn_error_clear(err);
}
Modified: subversion/branches/authzperf/subversion/libsvn_subr/packed_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/packed_data.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/packed_data.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/packed_data.c Fri Apr 29 18:38:53 2016
@@ -308,7 +308,7 @@ unmap_uint(apr_uint64_t value)
* are no sub-streams).
*/
static void
-svn_packed__data_flush_buffer(svn_packed__int_stream_t *stream)
+data_flush_buffer(svn_packed__int_stream_t *stream)
{
packed_int_private_t *private_data = stream->private_data;
apr_size_t i;
@@ -382,7 +382,7 @@ svn_packed__add_uint(svn_packed__int_str
{
stream->buffer[stream->buffer_used] = value;
if (++stream->buffer_used == SVN__PACKED_DATA_BUFFER_SIZE)
- svn_packed__data_flush_buffer(stream);
+ data_flush_buffer(stream);
}
void
@@ -435,7 +435,7 @@ write_int_stream_structure(svn_stringbuf
+ (private_data->is_signed ? 2 : 0));
/* store item count and length their of packed representation */
- svn_packed__data_flush_buffer(stream);
+ data_flush_buffer(stream);
write_packed_uint(tree_struct, private_data->item_count);
write_packed_uint(tree_struct, private_data->packed
@@ -676,6 +676,12 @@ svn_packed__byte_count(svn_packed__byte_
return stream->packed->len;
}
+apr_size_t
+svn_packed__byte_block_count(svn_packed__byte_stream_t *stream)
+{
+ return svn_packed__int_count(stream->lengths_stream);
+}
+
/* Read one 7b/8b encoded value from *P and return it in *RESULT. Returns
* the first position after the parsed data.
*
Modified: subversion/branches/authzperf/subversion/libsvn_subr/path.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/path.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/path.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/path.c Fri Apr 29 18:38:53 2016
@@ -506,7 +506,7 @@ get_path_ancestor_length(const char *pat
else
if (last_dirsep == 0 && path1[0] == '/' && path2[0] == '/')
return 1;
- return last_dirsep;
+ return last_dirsep;
}
@@ -910,9 +910,24 @@ uri_escape(const char *path, const char
svn_stringbuf_t *retstr;
apr_size_t i, copied = 0;
int c;
+ apr_size_t len;
+ const char *p;
- retstr = svn_stringbuf_create_ensure(strlen(path), pool);
- for (i = 0; path[i]; i++)
+ /* To terminate our scanning loop, table[NUL] must report "invalid". */
+ assert(table[0] == 0);
+
+ /* Quick check: Does any character need escaping? */
+ for (p = path; table[(unsigned char)*p]; ++p)
+ {}
+
+ /* No char to escape before EOS? */
+ if (*p == '\0')
+ return path;
+
+ /* We need to escape at least one character. */
+ len = strlen(p) + (p - path);
+ retstr = svn_stringbuf_create_ensure(len, pool);
+ for (i = p - path; i < len; i++)
{
c = (unsigned char)path[i];
if (table[c])
@@ -941,10 +956,6 @@ uri_escape(const char *path, const char
copied = i + 1;
}
- /* If we didn't encode anything, we don't need to duplicate the string. */
- if (retstr->len == 0)
- return path;
-
/* Anything left to copy? */
if (i - copied)
svn_stringbuf_appendbytes(retstr, path + copied, i - copied);
@@ -971,7 +982,7 @@ svn_path_uri_encode(const char *path, ap
}
static const char iri_escape_chars[256] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -998,7 +1009,7 @@ svn_path_uri_from_iri(const char *iri, a
}
static const char uri_autoescape_chars[256] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
Modified: subversion/branches/authzperf/subversion/libsvn_subr/pool.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/pool.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/pool.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/pool.c Fri Apr 29 18:38:53 2016
@@ -54,6 +54,13 @@ abort_on_pool_failure(int retcode)
/* Don't translate this string! It requires memory allocation to do so!
And we don't have any of it... */
printf("libsvn: Out of memory - terminating application.\n");
+
+#ifdef WIN32
+ /* Provide a way to distinguish the out-of-memory error from abort(). */
+ if (retcode == APR_ENOMEM)
+ RaiseException(STATUS_NO_MEMORY, EXCEPTION_NONCONTINUABLE, 0, NULL);
+#endif
+
abort();
return 0; /* not reached */
}
Modified: subversion/branches/authzperf/subversion/libsvn_subr/prefix_string.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/prefix_string.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/prefix_string.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/prefix_string.c Fri Apr 29 18:38:53 2016
@@ -49,7 +49,12 @@ struct svn_prefix_string__t
/* mandatory prefix */
node_t *prefix;
- /* 0 ..7 chars to add the the prefix. NUL-terminated. */
+ /* 0 ..7 chars to add the the prefix.
+ *
+ * NUL-terminated, if this is indeed a tree leaf. We use the same struct
+ * within node_t for inner tree nodes, too. There, DATA[7] is not NUL,
+ * meaning DATA may or may not be NUL terminated. The actual length is
+ * provided by the node_t.length field (minus parent node length). */
char data[8];
};
@@ -94,6 +99,12 @@ struct svn_prefix_tree__t
static svn_boolean_t
is_leaf(node_t *node)
{
+ /* If this NOT a leaf node and this node has ...
+ * ... 8 chars, data[7] will not be NUL because we only support
+ * NUL-*terminated* strings.
+ * ... less than 8 chars, this will be set to 0xff
+ * (any other non-NUL would do as well but this is not valid UTF8
+ * making it easy to recognize during debugging etc.) */
return node->key.data[7] == 0;
}
@@ -154,7 +165,7 @@ svn_prefix_tree__create(apr_pool_t *pool
tree->pool = pool;
tree->root = apr_pcalloc(pool, sizeof(*tree->root));
- tree->root->key.data[7] = '\xff';
+ tree->root->key.data[7] = '\xff'; /* This is not a leaf. See is_leaf(). */
return tree;
}
@@ -188,6 +199,7 @@ svn_prefix_string__create(svn_prefix_tre
|| node->sub_nodes[idx]->key.data[0] != s[node->length])
break;
+ /* Yes, it matches - at least the first character does. */
sub_node = node->sub_nodes[idx];
/* fully matching sub-node? */
@@ -198,6 +210,11 @@ svn_prefix_string__create(svn_prefix_tre
}
else
{
+ /* The string formed by the path from the root down to
+ * SUB_NODE differs from S.
+ *
+ * Is it a prefix? In that case, the chars added by SUB_NODE
+ * must fully match the respective chars in S. */
apr_size_t sub_node_len = sub_node->length - node->length;
if (strncmp(sub_node->key.data, s + node->length,
sub_node_len) == 0)
@@ -207,14 +224,24 @@ svn_prefix_string__create(svn_prefix_tre
}
}
- /* partial match -> split */
+ /* partial match -> split
+ *
+ * At this point, S may either be a prefix to the string represented
+ * by SUB_NODE, or they may diverge at some offset with
+ * SUB_NODE->KEY.DATA .
+ *
+ * MATCH starts with 1 here b/c we already know that at least one
+ * char matches. Also, the loop will terminate because the strings
+ * differ before SUB_NODE->KEY.DATA - either at the NUL terminator
+ * of S or some char before that.
+ */
while (sub_node->key.data[match] == s[node->length + match])
++match;
new_node = apr_pcalloc(tree->pool, sizeof(*new_node));
new_node->key = sub_node->key;
new_node->length = node->length + match;
- new_node->key.data[7] = '\xff';
+ new_node->key.data[7] = '\xff'; /* This is not a leaf. See is_leaf(). */
new_node->sub_node_count = 1;
new_node->sub_nodes = apr_palloc(tree->pool, sizeof(node_t *));
new_node->sub_nodes[0] = sub_node;
@@ -228,7 +255,7 @@ svn_prefix_string__create(svn_prefix_tre
}
/* add sub-node(s) and final string */
- while (node->length + 7 < len)
+ while (len - node->length > 7)
{
new_node = apr_pcalloc(tree->pool, sizeof(*new_node));
new_node->key.prefix = node;
Modified: subversion/branches/authzperf/subversion/libsvn_subr/prompt.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/prompt.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/prompt.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/prompt.c Fri Apr 29 18:38:53 2016
@@ -814,6 +814,8 @@ plaintext_prompt_helper(svn_boolean_t *m
const char *config_path = NULL;
terminal_handle_t *terminal;
+ *may_save_plaintext = FALSE; /* de facto API promise */
+
if (pb)
SVN_ERR(svn_config_get_user_config_path(&config_path, pb->config_dir,
SVN_CONFIG_CATEGORY_SERVERS, pool));
@@ -826,18 +828,7 @@ plaintext_prompt_helper(svn_boolean_t *m
do
{
- svn_error_t *err = prompt(&answer, prompt_string, FALSE, pb, pool);
- if (err)
- {
- if (err->apr_err == SVN_ERR_CANCELLED)
- {
- svn_error_clear(err);
- *may_save_plaintext = FALSE;
- return SVN_NO_ERROR;
- }
- else
- return err;
- }
+ SVN_ERR(prompt(&answer, prompt_string, FALSE, pb, pool));
if (apr_strnatcasecmp(answer, _("yes")) == 0 ||
apr_strnatcasecmp(answer, _("y")) == 0)
{
Modified: subversion/branches/authzperf/subversion/libsvn_subr/skel.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/skel.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/skel.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/skel.c Fri Apr 29 18:38:53 2016
@@ -380,7 +380,7 @@ explicit_atom(const char *data,
data++;
/* Check the length. */
- if (data + size > end)
+ if (end - data < size)
return NULL;
/* Allocate the skel representing this string. */
Modified: subversion/branches/authzperf/subversion/libsvn_subr/sorts.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/sorts.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/sorts.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/sorts.c Fri Apr 29 18:38:53 2016
@@ -333,7 +333,7 @@ svn_sort__array_delete(apr_array_header_
if (delete_index >= 0
&& delete_index < arr->nelts
&& elements_to_delete > 0
- && (elements_to_delete + delete_index) <= arr->nelts)
+ && (arr->nelts - delete_index) >= elements_to_delete)
{
/* If we are not deleting a block of elements that extends to the end
of the array, then we need to move the remaining elements to keep
Modified: subversion/branches/authzperf/subversion/libsvn_subr/spillbuf.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/spillbuf.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/spillbuf.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/spillbuf.c Fri Apr 29 18:38:53 2016
@@ -242,7 +242,7 @@ svn_spillbuf__write(svn_spillbuf_t *buf,
will grow too large. Create the file and place the pending data into
the temporary file. */
if (buf->spill == NULL
- && (buf->memory_size + len) > buf->maxsize)
+ && ((buf->maxsize - buf->memory_size) < len))
{
SVN_ERR(svn_io_open_unique_file3(&buf->spill,
&buf->filename,
Modified: subversion/branches/authzperf/subversion/libsvn_subr/sqlite.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/sqlite.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/sqlite.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/sqlite.c Fri Apr 29 18:38:53 2016
@@ -1171,6 +1171,7 @@ svn_sqlite__open(svn_sqlite__db_t **db,
affects application(read: Subversion) performance/behavior. */
"PRAGMA foreign_keys=OFF;" /* SQLITE_DEFAULT_FOREIGN_KEYS*/
"PRAGMA locking_mode = NORMAL;" /* SQLITE_DEFAULT_LOCKING_MODE */
+ /* Testing shows TRUNCATE is faster than DELETE on Windows. */
"PRAGMA journal_mode = TRUNCATE;"
),
*db);
@@ -1260,6 +1261,54 @@ reset_all_statements(svn_sqlite__db_t *d
return err;
}
+static svn_error_t *
+rollback_transaction(svn_sqlite__db_t *db,
+ svn_error_t *error_to_wrap)
+{
+ svn_sqlite__stmt_t *stmt;
+ svn_error_t *err;
+
+ err = get_internal_statement(&stmt, db, STMT_INTERNAL_ROLLBACK_TRANSACTION);
+ if (!err)
+ {
+ err = svn_error_trace(svn_sqlite__step_done(stmt));
+
+ if (err && err->apr_err == SVN_ERR_SQLITE_BUSY)
+ {
+ /* ### Houston, we have a problem!
+
+ We are trying to rollback but we can't because some
+ statements are still busy. This leaves the database
+ unusable for future transactions as the current transaction
+ is still open.
+
+ As we are returning the actual error as the most relevant
+ error in the chain, our caller might assume that it can
+ retry/compensate on this error (e.g. SVN_WC_LOCKED), while
+ in fact the SQLite database is unusable until the statements
+ started within this transaction are reset and the transaction
+ aborted.
+
+ We try to compensate by resetting all prepared but unreset
+ statements; but we leave the busy error in the chain anyway to
+ help diagnosing the original error and help in finding where
+ a reset statement is missing. */
+ err = svn_error_trace(reset_all_statements(db, err));
+ err = svn_error_compose_create(
+ svn_error_trace(svn_sqlite__step_done(stmt)),
+ err);
+ }
+ }
+
+ if (err)
+ {
+ /* Rollback failed, use a specific error code. */
+ err = svn_error_create(SVN_ERR_SQLITE_ROLLBACK_FAILED, err, NULL);
+ }
+
+ return svn_error_compose_create(error_to_wrap, err);
+}
+
svn_error_t *
svn_sqlite__begin_transaction(svn_sqlite__db_t *db)
{
@@ -1302,46 +1351,37 @@ svn_sqlite__finish_transaction(svn_sqlit
/* Commit or rollback the sqlite transaction. */
if (err)
{
- svn_error_t *err2;
-
- err2 = get_internal_statement(&stmt, db,
- STMT_INTERNAL_ROLLBACK_TRANSACTION);
- if (!err2)
- err2 = svn_error_trace(svn_sqlite__step_done(stmt));
-
- if (err2 && err2->apr_err == SVN_ERR_SQLITE_BUSY)
- {
- /* ### Houston, we have a problem!
-
- We are trying to rollback but we can't because some
- statements are still busy. This leaves the database
- unusable for future transactions as the current transaction
- is still open.
-
- As we are returning the actual error as the most relevant
- error in the chain, our caller might assume that it can
- retry/compensate on this error (e.g. SVN_WC_LOCKED), while
- in fact the SQLite database is unusable until the statements
- started within this transaction are reset and the transaction
- aborted.
-
- We try to compensate by resetting all prepared but unreset
- statements; but we leave the busy error in the chain anyway to
- help diagnosing the original error and help in finding where
- a reset statement is missing. */
-
- err2 = svn_error_trace(reset_all_statements(db, err2));
- err2 = svn_error_compose_create(
- svn_error_trace(svn_sqlite__step_done(stmt)),
- err2);
-
- }
-
- return svn_error_compose_create(err, err2);
+ return svn_error_trace(rollback_transaction(db, err));
+ }
+ else
+ {
+ err = get_internal_statement(&stmt, db,
+ STMT_INTERNAL_COMMIT_TRANSACTION);
+ if (!err)
+ err = svn_error_trace(svn_sqlite__step_done(stmt));
+
+ /* Need to rollback if the commit fails as well, because otherwise the
+ db connection will be left in an unusable state.
+
+ One important case to keep in mind is trying to COMMIT with concurrent
+ readers. In case the commit fails, because someone else is holding a
+ shared lock, sqlite keeps the transaction, and *also* keeps the file
+ locks on the database. While the first part only prevents from using
+ this connection, the second part prevents everyone else from accessing
+ the database while the connection is open.
+
+ See https://www.sqlite.org/lang_transaction.html
+
+ COMMIT might also result in an SQLITE_BUSY return code if an another
+ thread or process has a shared lock on the database that prevented
+ the database from being updated. When COMMIT fails in this way, the
+ transaction remains active and the COMMIT can be retried later after
+ the reader has had a chance to clear. */
+ if (err)
+ return svn_error_trace(rollback_transaction(db, err));
}
- SVN_ERR(get_internal_statement(&stmt, db, STMT_INTERNAL_COMMIT_TRANSACTION));
- return svn_error_trace(svn_sqlite__step_done(stmt));
+ return SVN_NO_ERROR;
}
svn_error_t *
@@ -1358,20 +1398,22 @@ svn_sqlite__finish_savepoint(svn_sqlite_
STMT_INTERNAL_ROLLBACK_TO_SAVEPOINT_SVN);
if (!err2)
- err2 = svn_error_trace(svn_sqlite__step_done(stmt));
-
- if (err2 && err2->apr_err == SVN_ERR_SQLITE_BUSY)
{
- /* Ok, we have a major problem. Some statement is still open, which
- makes it impossible to release this savepoint.
+ err2 = svn_error_trace(svn_sqlite__step_done(stmt));
- ### See huge comment in svn_sqlite__finish_transaction for
- further details */
-
- err2 = svn_error_trace(reset_all_statements(db, err2));
- err2 = svn_error_compose_create(
- svn_error_trace(svn_sqlite__step_done(stmt)),
- err2);
+ if (err2 && err2->apr_err == SVN_ERR_SQLITE_BUSY)
+ {
+ /* Ok, we have a major problem. Some statement is still open,
+ which makes it impossible to release this savepoint.
+
+ ### See huge comment in rollback_transaction() for
+ further details */
+
+ err2 = svn_error_trace(reset_all_statements(db, err2));
+ err2 = svn_error_compose_create(
+ svn_error_trace(svn_sqlite__step_done(stmt)),
+ err2);
+ }
}
err = svn_error_compose_create(err, err2);
@@ -1387,6 +1429,8 @@ svn_sqlite__finish_savepoint(svn_sqlite_
SVN_ERR(get_internal_statement(&stmt, db,
STMT_INTERNAL_RELEASE_SAVEPOINT_SVN));
+ /* ### Releasing a savepoint can fail and leave the db connection
+ unusable; see svn_sqlite__finish_transaction(). */
return svn_error_trace(svn_sqlite__step_done(stmt));
}
Modified: subversion/branches/authzperf/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/stream.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/stream.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/stream.c Fri Apr 29 18:38:53 2016
@@ -42,6 +42,7 @@
#include "svn_checksum.h"
#include "svn_path.h"
#include "svn_private_config.h"
+#include "svn_sorts.h"
#include "private/svn_atomic.h"
#include "private/svn_error_private.h"
#include "private/svn_eol_private.h"
@@ -924,8 +925,7 @@ mark_handler_apr(void *baton, svn_stream
struct mark_apr *mark_apr;
mark_apr = apr_palloc(pool, sizeof(*mark_apr));
- mark_apr->off = 0;
- SVN_ERR(svn_io_file_seek(btn->file, APR_CUR, &mark_apr->off, btn->pool));
+ SVN_ERR(svn_io_file_get_offset(&mark_apr->off, btn->file, btn->pool));
*mark = (svn_stream_mark_t *)mark_apr;
return SVN_NO_ERROR;
}
@@ -1480,32 +1480,44 @@ svn_stream_checksummed2(svn_stream_t *st
/* Miscellaneous stream functions. */
+/*
+ * [JAF] By considering the buffer size doubling algorithm we use, I think
+ * the performance characteristics of this implementation are as follows:
+ *
+ * When the effective hint is big enough for the actual data, it uses
+ * minimal time and allocates space roughly equal to the effective hint.
+ * Otherwise, it incurs a time overhead for copying an additional 1x to 2x
+ * the actual length of data, and a space overhead of an additional 2x to
+ * 3x the actual length.
+ */
svn_error_t *
-svn_stringbuf_from_stream(svn_stringbuf_t **str,
+svn_stringbuf_from_stream(svn_stringbuf_t **result,
svn_stream_t *stream,
apr_size_t len_hint,
apr_pool_t *result_pool)
{
#define MIN_READ_SIZE 64
-
- apr_size_t to_read = 0;
svn_stringbuf_t *text
- = svn_stringbuf_create_ensure(len_hint ? len_hint : MIN_READ_SIZE,
+ = svn_stringbuf_create_ensure(MAX(len_hint + 1, MIN_READ_SIZE),
result_pool);
- do
+ while(TRUE)
{
- to_read = text->blocksize - 1 - text->len;
- SVN_ERR(svn_stream_read_full(stream, text->data + text->len, &to_read));
- text->len += to_read;
+ apr_size_t to_read = text->blocksize - 1 - text->len;
+ apr_size_t actually_read = to_read;
+
+ SVN_ERR(svn_stream_read_full(stream, text->data + text->len, &actually_read));
+ text->len += actually_read;
+
+ if (actually_read < to_read)
+ break;
- if (to_read && text->blocksize < text->len + MIN_READ_SIZE)
+ if (text->blocksize - text->len < MIN_READ_SIZE)
svn_stringbuf_ensure(text, text->blocksize * 2);
}
- while (to_read);
text->data[text->len] = '\0';
- *str = text;
+ *result = text;
return SVN_NO_ERROR;
}
@@ -1793,32 +1805,18 @@ svn_stream_for_stderr(svn_stream_t **err
svn_error_t *
-svn_string_from_stream(svn_string_t **result,
- svn_stream_t *stream,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
+svn_string_from_stream2(svn_string_t **result,
+ svn_stream_t *stream,
+ apr_size_t len_hint,
+ apr_pool_t *result_pool)
{
- svn_stringbuf_t *work = svn_stringbuf_create_ensure(SVN__STREAM_CHUNK_SIZE,
- result_pool);
- char *buffer = apr_palloc(scratch_pool, SVN__STREAM_CHUNK_SIZE);
+ svn_stringbuf_t *buf;
- while (1)
- {
- apr_size_t len = SVN__STREAM_CHUNK_SIZE;
-
- SVN_ERR(svn_stream_read_full(stream, buffer, &len));
- svn_stringbuf_appendbytes(work, buffer, len);
-
- if (len < SVN__STREAM_CHUNK_SIZE)
- break;
- }
+ SVN_ERR(svn_stringbuf_from_stream(&buf, stream, len_hint, result_pool));
+ *result = svn_stringbuf__morph_into_string(buf);
SVN_ERR(svn_stream_close(stream));
- *result = apr_palloc(result_pool, sizeof(**result));
- (*result)->data = work->data;
- (*result)->len = work->len;
-
return SVN_NO_ERROR;
}
Modified: subversion/branches/authzperf/subversion/libsvn_subr/string.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/string.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/string.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/string.c Fri Apr 29 18:38:53 2016
@@ -696,7 +696,7 @@ svn_stringbuf_remove(svn_stringbuf_t *st
{
if (pos > str->len)
pos = str->len;
- if (pos + count > str->len)
+ if (count > str->len - pos)
count = str->len - pos;
memmove(str->data + pos, str->data + pos + count, str->len - pos - count + 1);
@@ -724,7 +724,7 @@ svn_stringbuf_replace(svn_stringbuf_t *s
if (pos > str->len)
pos = str->len;
- if (pos + old_count > str->len)
+ if (old_count > str->len - pos)
old_count = str->len - pos;
if (old_count < new_count)
@@ -1510,7 +1510,7 @@ svn_cstring__match_length(const char *a,
* because A and B will probably have different alignment. So, skipping
* the first few chars until alignment is reached is not an option.
*/
- for (; pos + sizeof(apr_size_t) <= max_len; pos += sizeof(apr_size_t))
+ for (; max_len - pos >= sizeof(apr_size_t); pos += sizeof(apr_size_t))
if (*(const apr_size_t*)(a + pos) != *(const apr_size_t*)(b + pos))
break;
Modified: subversion/branches/authzperf/subversion/libsvn_subr/subst.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/subst.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/subst.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/subst.c Fri Apr 29 18:38:53 2016
@@ -1127,7 +1127,7 @@ translate_chunk(svn_stream_t *dst,
{
/* Check 4 bytes at once to allow for efficient pipelining
and to reduce loop condition overhead. */
- while ((p + len + 4) <= end)
+ while ((end - p) >= (len + 4))
{
if (interesting[(unsigned char)p[len]]
|| interesting[(unsigned char)p[len+1]]
@@ -1157,7 +1157,7 @@ translate_chunk(svn_stream_t *dst,
}
while (b->nl_translation_skippable ==
svn_tristate_true && /* can potentially skip EOLs */
- p + len + 2 < end && /* not too close to EOF */
+ (end - p) > (len + 2) && /* not too close to EOF */
eol_unchanged(b, p + len)); /* EOL format already ok */
while ((p + len) < end && !interesting[(unsigned char)p[len]])
Modified: subversion/branches/authzperf/subversion/libsvn_subr/sysinfo.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/sysinfo.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/sysinfo.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/sysinfo.c Fri Apr 29 18:38:53 2016
@@ -1143,6 +1143,7 @@ release_name_from_version(const char *os
case 8: return "Mountain Lion";
case 9: return "Mavericks";
case 10: return "Yosemite";
+ case 11: return "El Capitan";
}
return NULL;
Modified: subversion/branches/authzperf/subversion/libsvn_subr/utf8proc.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/utf8proc.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/utf8proc.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/utf8proc.c Fri Apr 29 18:38:53 2016
@@ -126,15 +126,30 @@ decompose_normalized(apr_size_t *result_
* STRING. Upon return, BUFFER->data points at a NUL-terminated string
* of UTF-8 characters.
*
+ * If CASEFOLD is non-zero, perform Unicode case folding, e.g., for
+ * case-insensitive string comparison. If STRIPMARK is non-zero, strip
+ * all diacritical marks (e.g., accents) from the string.
+ *
* A returned error may indicate that STRING contains invalid UTF-8 or
* invalid Unicode codepoints. Any error message comes from utf8proc.
*/
static svn_error_t *
normalize_cstring(apr_size_t *result_length,
const char *string, apr_size_t length,
+ svn_boolean_t casefold,
+ svn_boolean_t stripmark,
svn_membuf_t *buffer)
{
- ssize_t result = unicode_decomposition(0, string, length, buffer);
+ int flags = 0;
+ ssize_t result;
+
+ if (casefold)
+ flags |= UTF8PROC_CASEFOLD;
+
+ if (stripmark)
+ flags |= UTF8PROC_STRIPMARK;
+
+ result = unicode_decomposition(flags, string, length, buffer);
if (result >= 0)
{
svn_membuf__resize(buffer, result * sizeof(apr_int32_t) + 1);
@@ -202,7 +217,21 @@ svn_utf__normalize(const char **result,
svn_membuf_t *buf)
{
apr_size_t result_length;
- SVN_ERR(normalize_cstring(&result_length, str, len, buf));
+ SVN_ERR(normalize_cstring(&result_length, str, len, FALSE, FALSE, buf));
+ *result = (const char*)(buf->data);
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_utf__xfrm(const char **result,
+ const char *str, apr_size_t len,
+ svn_boolean_t case_insensitive,
+ svn_boolean_t accent_insensitive,
+ svn_membuf_t *buf)
+{
+ apr_size_t result_length;
+ SVN_ERR(normalize_cstring(&result_length, str, len,
+ case_insensitive, accent_insensitive, buf));
*result = (const char*)(buf->data);
return SVN_NO_ERROR;
}
@@ -359,7 +388,8 @@ svn_utf__is_normalized(const char *strin
apr_size_t result_length;
const apr_size_t length = strlen(string);
svn_membuf__create(&buffer, length * sizeof(apr_int32_t), scratch_pool);
- err = normalize_cstring(&result_length, string, length, &buffer);
+ err = normalize_cstring(&result_length, string, length,
+ FALSE, FALSE, &buffer);
if (err)
{
svn_error_clear(err);
Modified: subversion/branches/authzperf/subversion/libsvn_subr/utf_validate.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/utf_validate.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/utf_validate.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/utf_validate.c Fri Apr 29 18:38:53 2016
@@ -258,24 +258,7 @@ static const char machine [9][14] = {
static const char *
first_non_fsm_start_char(const char *data, apr_size_t max_len)
{
-#if !SVN_UNALIGNED_ACCESS_IS_OK
-
- /* On some systems, we need to make sure that buf is properly aligned
- * for chunky data access.
- */
- if ((apr_uintptr_t)data & (sizeof(apr_uintptr_t)-1))
- {
- apr_size_t len = (~(apr_uintptr_t)data) & (sizeof(apr_uintptr_t)-1);
- if (len > max_len)
- len = max_len;
- max_len -= len;
-
- for (; len > 0; ++data, --len)
- if ((unsigned char)*data >= 0x80)
- return data;
- }
-
-#endif
+#if SVN_UNALIGNED_ACCESS_IS_OK
/* Scan the input one machine word at a time. */
for (; max_len > sizeof(apr_uintptr_t)
@@ -283,55 +266,11 @@ first_non_fsm_start_char(const char *dat
if (*(const apr_uintptr_t *)data & SVN__BIT_7_SET)
break;
- /* The remaining odd bytes will be examined the naive way: */
- for (; max_len > 0; ++data, --max_len)
- if ((unsigned char)*data >= 0x80)
- break;
-
- return data;
-}
-
-/* Scan the C string in *DATA for chars that are not in the octet
- * category 0 (FSM_START). Return the position of either the such
- * char or of the terminating NUL.
- */
-static const char *
-first_non_fsm_start_char_cstring(const char *data)
-{
- /* We need to make sure that BUF is properly aligned for chunky data
- * access because we don't know the string's length. Unaligned chunk
- * read access beyond the NUL terminator could therefore result in a
- * segfault.
- */
- for (; (apr_uintptr_t)data & (sizeof(apr_uintptr_t)-1); ++data)
- if (*data == 0 || (unsigned char)*data >= 0x80)
- return data;
-
- /* Scan the input one machine word at a time. */
-#ifndef SVN_UTF_NO_UNINITIALISED_ACCESS
- /* This may read allocated but uninitialised bytes beyond the
- terminating null. Any such bytes are always readable and this
- code operates correctly whatever the uninitialised values happen
- to be. However memory checking tools such as valgrind and GCC
- 4.8's address santitizer will object so this bit of code can be
- disabled at compile time. */
- for (; ; data += sizeof(apr_uintptr_t))
- {
- /* Check for non-ASCII chars: */
- apr_uintptr_t chunk = *(const apr_uintptr_t *)data;
- if (chunk & SVN__BIT_7_SET)
- break;
-
- /* This is the well-known strlen test: */
- chunk |= (chunk & SVN__LOWER_7BITS_SET) + SVN__LOWER_7BITS_SET;
- if ((chunk & SVN__BIT_7_SET) != SVN__BIT_7_SET)
- break;
- }
#endif
/* The remaining odd bytes will be examined the naive way: */
- for (; ; ++data)
- if (*data == 0 || (unsigned char)*data >= 0x80)
+ for (; max_len > 0; ++data, --max_len)
+ if ((unsigned char)*data >= 0x80)
break;
return data;
@@ -359,20 +298,10 @@ svn_utf__last_valid(const char *data, ap
svn_boolean_t
svn_utf__cstring_is_valid(const char *data)
{
- int state = FSM_START;
-
if (!data)
return FALSE;
- data = first_non_fsm_start_char_cstring(data);
-
- while (*data)
- {
- unsigned char octet = *data++;
- int category = octet_category[octet];
- state = machine[state][category];
- }
- return state == FSM_START;
+ return svn_utf__is_valid(data, strlen(data));
}
svn_boolean_t
Modified: subversion/branches/authzperf/subversion/libsvn_subr/version.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/version.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/version.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/version.c Fri Apr 29 18:38:53 2016
@@ -143,7 +143,7 @@ svn_version_extended(svn_boolean_t verbo
info->build_time = __TIME__;
info->build_host = SVN_BUILD_HOST;
info->copyright = apr_pstrdup
- (pool, _("Copyright (C) 2015 The Apache Software Foundation.\n"
+ (pool, _("Copyright (C) 2016 The Apache Software Foundation.\n"
"This software consists of contributions made by many people;\n"
"see the NOTICE file for more information.\n"
"Subversion is open source software, see "
Modified: subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt.c Fri Apr 29 18:38:53 2016
@@ -84,32 +84,33 @@ convert_wbcs_to_ansi(const wchar_t *str)
static const char *
exception_string(int exception)
{
-#define EXCEPTION(x) case EXCEPTION_##x: return (#x);
+#define EXCEPTION(x) case x: return (#x);
switch (exception)
{
- EXCEPTION(ACCESS_VIOLATION)
- EXCEPTION(DATATYPE_MISALIGNMENT)
- EXCEPTION(BREAKPOINT)
- EXCEPTION(SINGLE_STEP)
- EXCEPTION(ARRAY_BOUNDS_EXCEEDED)
- EXCEPTION(FLT_DENORMAL_OPERAND)
- EXCEPTION(FLT_DIVIDE_BY_ZERO)
- EXCEPTION(FLT_INEXACT_RESULT)
- EXCEPTION(FLT_INVALID_OPERATION)
- EXCEPTION(FLT_OVERFLOW)
- EXCEPTION(FLT_STACK_CHECK)
- EXCEPTION(FLT_UNDERFLOW)
- EXCEPTION(INT_DIVIDE_BY_ZERO)
- EXCEPTION(INT_OVERFLOW)
- EXCEPTION(PRIV_INSTRUCTION)
- EXCEPTION(IN_PAGE_ERROR)
- EXCEPTION(ILLEGAL_INSTRUCTION)
- EXCEPTION(NONCONTINUABLE_EXCEPTION)
- EXCEPTION(STACK_OVERFLOW)
- EXCEPTION(INVALID_DISPOSITION)
- EXCEPTION(GUARD_PAGE)
- EXCEPTION(INVALID_HANDLE)
+ EXCEPTION(EXCEPTION_ACCESS_VIOLATION)
+ EXCEPTION(EXCEPTION_DATATYPE_MISALIGNMENT)
+ EXCEPTION(EXCEPTION_BREAKPOINT)
+ EXCEPTION(EXCEPTION_SINGLE_STEP)
+ EXCEPTION(EXCEPTION_ARRAY_BOUNDS_EXCEEDED)
+ EXCEPTION(EXCEPTION_FLT_DENORMAL_OPERAND)
+ EXCEPTION(EXCEPTION_FLT_DIVIDE_BY_ZERO)
+ EXCEPTION(EXCEPTION_FLT_INEXACT_RESULT)
+ EXCEPTION(EXCEPTION_FLT_INVALID_OPERATION)
+ EXCEPTION(EXCEPTION_FLT_OVERFLOW)
+ EXCEPTION(EXCEPTION_FLT_STACK_CHECK)
+ EXCEPTION(EXCEPTION_FLT_UNDERFLOW)
+ EXCEPTION(EXCEPTION_INT_DIVIDE_BY_ZERO)
+ EXCEPTION(EXCEPTION_INT_OVERFLOW)
+ EXCEPTION(EXCEPTION_PRIV_INSTRUCTION)
+ EXCEPTION(EXCEPTION_IN_PAGE_ERROR)
+ EXCEPTION(EXCEPTION_ILLEGAL_INSTRUCTION)
+ EXCEPTION(EXCEPTION_NONCONTINUABLE_EXCEPTION)
+ EXCEPTION(EXCEPTION_STACK_OVERFLOW)
+ EXCEPTION(EXCEPTION_INVALID_DISPOSITION)
+ EXCEPTION(EXCEPTION_GUARD_PAGE)
+ EXCEPTION(EXCEPTION_INVALID_HANDLE)
+ EXCEPTION(STATUS_NO_MEMORY)
default:
return "UNKNOWN_ERROR";
@@ -171,7 +172,7 @@ write_module_info_callback(void *data,
MINIDUMP_MODULE_CALLBACK module = callback_input->Module;
char *buf = convert_wbcs_to_ansi(module.FullPath);
- fprintf(log_file, FORMAT_PTR, (INT_PTR)module.BaseOfImage);
+ fprintf(log_file, FORMAT_PTR, (UINT_PTR)module.BaseOfImage);
fprintf(log_file, " %s", buf);
free(buf);
@@ -260,18 +261,19 @@ write_process_info(EXCEPTION_RECORD *exc
#endif
}
-/* Formats the value at address based on the specified basic type
- * (char, int, long ...). */
+/* Writes the value at address based on the specified basic type
+ * (char, int, long ...) to LOG_FILE. */
static void
-format_basic_type(char *buf, DWORD basic_type, DWORD64 length, void *address)
+write_basic_type(FILE *log_file, DWORD basic_type, DWORD64 length,
+ void *address)
{
switch(length)
{
case 1:
- sprintf(buf, "0x%02x", (int)*(unsigned char *)address);
+ fprintf(log_file, "0x%02x", (int)*(unsigned char *)address);
break;
case 2:
- sprintf(buf, "0x%04x", (int)*(unsigned short *)address);
+ fprintf(log_file, "0x%04x", (int)*(unsigned short *)address);
break;
case 4:
switch(basic_type)
@@ -279,38 +281,38 @@ format_basic_type(char *buf, DWORD basic
case 2: /* btChar */
{
if (!IsBadStringPtr(*(PSTR*)address, 32))
- sprintf(buf, "\"%.31s\"", *(const char **)address);
+ fprintf(log_file, "\"%.31s\"", *(const char **)address);
else
- sprintf(buf, FORMAT_PTR, *(DWORD_PTR *)address);
+ fprintf(log_file, FORMAT_PTR, *(DWORD_PTR *)address);
}
case 6: /* btInt */
- sprintf(buf, "%d", *(int *)address);
+ fprintf(log_file, "%d", *(int *)address);
break;
case 8: /* btFloat */
- sprintf(buf, "%f", *(float *)address);
+ fprintf(log_file, "%f", *(float *)address);
break;
default:
- sprintf(buf, FORMAT_PTR, *(DWORD_PTR *)address);
+ fprintf(log_file, FORMAT_PTR, *(DWORD_PTR *)address);
break;
}
break;
case 8:
if (basic_type == 8) /* btFloat */
- sprintf(buf, "%lf", *(double *)address);
+ fprintf(log_file, "%lf", *(double *)address);
else
- sprintf(buf, "0x%016I64X", *(unsigned __int64 *)address);
+ fprintf(log_file, "0x%016I64X", *(unsigned __int64 *)address);
break;
default:
- sprintf(buf, "[unhandled type 0x%08x of length " FORMAT_PTR "]",
- basic_type, (INT_PTR)length);
+ fprintf(log_file, "[unhandled type 0x%08x of length " FORMAT_PTR "]",
+ basic_type, (UINT_PTR)length);
break;
}
}
-/* Formats the value at address based on the type (pointer, user defined,
- * basic type). */
+/* Writes the value at address based on the type (pointer, user defined,
+ * basic type) to LOG_FILE. */
static void
-format_value(char *value_str, DWORD64 mod_base, DWORD type, void *value_addr)
+write_value(FILE *log_file, DWORD64 mod_base, DWORD type, void *value_addr)
{
DWORD tag = 0;
int ptr = 0;
@@ -340,19 +342,19 @@ format_value(char *value_str, DWORD64 mo
LocalFree(type_name_wbcs);
if (ptr == 0)
- sprintf(value_str, "(%s) " FORMAT_PTR,
- type_name, (INT_PTR)(DWORD_PTR *)value_addr);
+ fprintf(log_file, "(%s) " FORMAT_PTR,
+ type_name, (UINT_PTR)(DWORD_PTR *)value_addr);
else if (ptr == 1)
- sprintf(value_str, "(%s *) " FORMAT_PTR,
+ fprintf(log_file, "(%s *) " FORMAT_PTR,
type_name, *(DWORD_PTR *)value_addr);
else
- sprintf(value_str, "(%s **) " FORMAT_PTR,
+ fprintf(log_file, "(%s **) " FORMAT_PTR,
type_name, *(DWORD_PTR *)value_addr);
free(type_name);
}
else
- sprintf(value_str, "[no symbol tag]");
+ fprintf(log_file, "[no symbol tag]");
}
break;
case 16: /* SymTagBaseType */
@@ -364,27 +366,27 @@ format_value(char *value_str, DWORD64 mo
/* print a char * as a string */
if (ptr == 1 && length == 1)
{
- sprintf(value_str, FORMAT_PTR " \"%s\"",
+ fprintf(log_file, FORMAT_PTR " \"%s\"",
*(DWORD_PTR *)value_addr, *(const char **)value_addr);
}
else if (ptr >= 1)
{
- sprintf(value_str, FORMAT_PTR, *(DWORD_PTR *)value_addr);
+ fprintf(log_file, FORMAT_PTR, *(DWORD_PTR *)value_addr);
}
else if (SymGetTypeInfo_(proc, mod_base, type, TI_GET_BASETYPE, &bt))
{
- format_basic_type(value_str, bt, length, value_addr);
+ write_basic_type(log_file, bt, length, value_addr);
}
}
break;
case 12: /* SymTagEnum */
- sprintf(value_str, "%d", *(DWORD_PTR *)value_addr);
+ fprintf(log_file, "%d", *(DWORD_PTR *)value_addr);
break;
case 13: /* SymTagFunctionType */
- sprintf(value_str, FORMAT_PTR, *(DWORD_PTR *)value_addr);
+ fprintf(log_file, FORMAT_PTR, *(DWORD_PTR *)value_addr);
break;
default:
- sprintf(value_str, "[unhandled tag: %d]", tag);
+ fprintf(log_file, "[unhandled tag: %d]", tag);
break;
}
}
@@ -408,7 +410,6 @@ write_var_values(PSYMBOL_INFO sym_info,
FILE *log_file = ((symbols_baton_t*)baton)->log_file;
int nr_of_frame = ((symbols_baton_t*)baton)->nr_of_frame;
BOOL log_params = ((symbols_baton_t*)baton)->log_params;
- char value_str[256] = "";
/* get the variable's data */
if (sym_info->Flags & SYMFLAG_REGREL)
@@ -426,17 +427,17 @@ write_var_values(PSYMBOL_INFO sym_info,
else
last_nr_of_frame = nr_of_frame;
- format_value(value_str, sym_info->ModBase, sym_info->TypeIndex,
- (void *)var_data);
- fprintf(log_file, "%.*s=%s", (int)sym_info->NameLen, sym_info->Name,
- value_str);
+ fprintf(log_file, "%.*s=", (int)sym_info->NameLen, sym_info->Name);
+ write_value(log_file, sym_info->ModBase, sym_info->TypeIndex,
+ (void *)var_data);
}
if (!log_params && sym_info->Flags & SYMFLAG_LOCAL)
{
- format_value(value_str, sym_info->ModBase, sym_info->TypeIndex,
- (void *)var_data);
- fprintf(log_file, " %.*s = %s\n", (int)sym_info->NameLen,
- sym_info->Name, value_str);
+ fprintf(log_file, " %.*s = ", (int)sym_info->NameLen,
+ sym_info->Name);
+ write_value(log_file, sym_info->ModBase, sym_info->TypeIndex,
+ (void *)var_data);
+ fprintf(log_file, "\n");
}
return TRUE;
Modified: subversion/branches/authzperf/subversion/libsvn_subr/x509info.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/x509info.c?rev=1741682&r1=1741681&r2=1741682&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/x509info.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/x509info.c Fri Apr 29 18:38:53 2016
@@ -311,7 +311,7 @@ svn_x509_certinfo_get_valid_from(const s
return certinfo->valid_from;
}
-const apr_time_t
+apr_time_t
svn_x509_certinfo_get_valid_to(const svn_x509_certinfo_t *certinfo)
{
return certinfo->valid_to;