summaryrefslogtreecommitdiffstats
path: root/subversion/libsvn_subr
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2013-11-11 01:00:29 +0000
committerpeter <peter@FreeBSD.org>2013-11-11 01:00:29 +0000
commit68301b10e52aedbf076b5b08303439d75c192e18 (patch)
treec05673887167c7ecd55a62ed72830f5186f453c1 /subversion/libsvn_subr
parent3b9f7e96381479fb03ae2c36d490a38718f71083 (diff)
downloadFreeBSD-src-68301b10e52aedbf076b5b08303439d75c192e18.zip
FreeBSD-src-68301b10e52aedbf076b5b08303439d75c192e18.tar.gz
Import svn-1.8.4, which includes fixes for both security and merge
handling.
Diffstat (limited to 'subversion/libsvn_subr')
-rw-r--r--subversion/libsvn_subr/auth.c4
-rw-r--r--subversion/libsvn_subr/cache_config.c75
-rw-r--r--subversion/libsvn_subr/cmdline.c4
-rw-r--r--subversion/libsvn_subr/config_auth.c6
-rw-r--r--subversion/libsvn_subr/deprecated.c9
-rw-r--r--subversion/libsvn_subr/dirent_uri.c6
-rw-r--r--subversion/libsvn_subr/internal_statements.h2
-rw-r--r--subversion/libsvn_subr/io.c2
-rw-r--r--subversion/libsvn_subr/sysinfo.c26
-rw-r--r--subversion/libsvn_subr/utf.c9
-rw-r--r--subversion/libsvn_subr/version.c15
-rw-r--r--subversion/libsvn_subr/win32_crashrpt.c12
12 files changed, 107 insertions, 63 deletions
diff --git a/subversion/libsvn_subr/auth.c b/subversion/libsvn_subr/auth.c
index 5406358..9dc4c77 100644
--- a/subversion/libsvn_subr/auth.c
+++ b/subversion/libsvn_subr/auth.c
@@ -36,6 +36,7 @@
#include "svn_dso.h"
#include "svn_version.h"
#include "private/svn_dep_compat.h"
+#include "private/svn_subr_private.h"
#include "auth.h"
@@ -478,7 +479,8 @@ svn_auth_get_platform_specific_provider(svn_auth_provider_object_t **provider,
check_list[0].version_query = version_function;
check_list[1].label = NULL;
check_list[1].version_query = NULL;
- SVN_ERR(svn_ver_check_list(svn_subr_version(), check_list));
+ SVN_ERR(svn_ver_check_list2(svn_subr_version(), check_list,
+ svn_ver_equal));
}
if (apr_dso_sym(&provider_function_symbol,
dso,
diff --git a/subversion/libsvn_subr/cache_config.c b/subversion/libsvn_subr/cache_config.c
index 86c12dc..17659f8 100644
--- a/subversion/libsvn_subr/cache_config.c
+++ b/subversion/libsvn_subr/cache_config.c
@@ -23,6 +23,7 @@
#include <apr_atomic.h>
#include "svn_cache_config.h"
+#include "private/svn_atomic.h"
#include "private/svn_cache.h"
#include "svn_pools.h"
@@ -69,30 +70,27 @@ svn_cache_config_get(void)
return &cache_settings;
}
-/* Access the process-global (singleton) membuffer cache. The first call
- * will automatically allocate the cache using the current cache config.
- * NULL will be returned if the desired cache size is 0 or if the cache
- * could not be created for some reason.
+/* Initializer function as required by svn_atomic__init_once. Allocate
+ * the process-global (singleton) membuffer cache and return it in the
+ * svn_membuffer_t * in *BATON. UNUSED_POOL is unused and should be NULL.
*/
-svn_membuffer_t *
-svn_cache__get_global_membuffer_cache(void)
+static svn_error_t *
+initialize_cache(void *baton, apr_pool_t *unused_pool)
{
- static svn_membuffer_t * volatile cache = NULL;
+ svn_membuffer_t **cache_p = baton;
+ svn_membuffer_t *cache = NULL;
apr_uint64_t cache_size = cache_settings.cache_size;
- if (!cache && cache_size)
+ if (cache_size)
{
svn_error_t *err;
- svn_membuffer_t *old_cache = NULL;
- svn_membuffer_t *new_cache = NULL;
-
/* auto-allocate cache */
apr_allocator_t *allocator = NULL;
apr_pool_t *pool = NULL;
if (apr_allocator_create(&allocator))
- return NULL;
+ return SVN_NO_ERROR;
/* Ensure that we free partially allocated data if we run OOM
* before the cache is complete: If the cache cannot be allocated
@@ -112,11 +110,11 @@ svn_cache__get_global_membuffer_cache(void)
*/
apr_pool_create_ex(&pool, NULL, NULL, allocator);
if (pool == NULL)
- return NULL;
+ return SVN_NO_ERROR;
apr_allocator_owner_set(allocator, pool);
err = svn_cache__membuffer_cache_create(
- &new_cache,
+ &cache,
(apr_size_t)cache_size,
(apr_size_t)(cache_size / 10),
0,
@@ -129,33 +127,40 @@ svn_cache__get_global_membuffer_cache(void)
*/
if (err)
{
- /* Memory and error cleanup */
- svn_error_clear(err);
+ /* Memory cleanup */
svn_pool_destroy(pool);
- /* Prevent future attempts to create the cache. However, an
- * existing cache instance (see next comment) remains valid.
- */
+ /* Document that we actually don't have a cache. */
cache_settings.cache_size = 0;
- /* The current caller won't get the cache object.
- * However, a concurrent call might have succeeded in creating
- * the cache object. That call and all following ones will then
- * use the successfully created cache instance.
- */
- return NULL;
+ return svn_error_trace(err);
}
- /* Handle race condition: if we are the first to create a
- * cache object, make it our global singleton. Otherwise,
- * discard the new cache and keep the existing one.
- *
- * Cast is necessary because of APR bug:
- * https://issues.apache.org/bugzilla/show_bug.cgi?id=50731
- */
- old_cache = apr_atomic_casptr((volatile void **)&cache, new_cache, NULL);
- if (old_cache != NULL)
- svn_pool_destroy(pool);
+ /* done */
+ *cache_p = cache;
+ }
+
+ return SVN_NO_ERROR;
+}
+
+/* Access the process-global (singleton) membuffer cache. The first call
+ * will automatically allocate the cache using the current cache config.
+ * NULL will be returned if the desired cache size is 0 or if the cache
+ * could not be created for some reason.
+ */
+svn_membuffer_t *
+svn_cache__get_global_membuffer_cache(void)
+{
+ static svn_membuffer_t *cache = NULL;
+ static svn_atomic_t initialized = 0;
+
+ svn_error_t *err
+ = svn_atomic__init_once(&initialized, initialize_cache, &cache, NULL);
+ if (err)
+ {
+ /* no caches today ... */
+ svn_error_clear(err);
+ return NULL;
}
return cache;
diff --git a/subversion/libsvn_subr/cmdline.c b/subversion/libsvn_subr/cmdline.c
index 8484c96..f52fa29 100644
--- a/subversion/libsvn_subr/cmdline.c
+++ b/subversion/libsvn_subr/cmdline.c
@@ -356,7 +356,7 @@ svn_cmdline_fputs(const char *string, FILE* stream, apr_pool_t *pool)
{
/* ### Issue #3014: Return a specific error for broken pipes,
* ### with a single element in the error chain. */
- if (APR_STATUS_IS_EPIPE(apr_get_os_error()))
+ if (SVN__APR_STATUS_IS_EPIPE(apr_get_os_error()))
return svn_error_create(SVN_ERR_IO_PIPE_WRITE_ERROR, NULL, NULL);
else
return svn_error_wrap_apr(apr_get_os_error(), _("Write error"));
@@ -379,7 +379,7 @@ svn_cmdline_fflush(FILE *stream)
{
/* ### Issue #3014: Return a specific error for broken pipes,
* ### with a single element in the error chain. */
- if (APR_STATUS_IS_EPIPE(apr_get_os_error()))
+ if (SVN__APR_STATUS_IS_EPIPE(apr_get_os_error()))
return svn_error_create(SVN_ERR_IO_PIPE_WRITE_ERROR, NULL, NULL);
else
return svn_error_wrap_apr(apr_get_os_error(), _("Write error"));
diff --git a/subversion/libsvn_subr/config_auth.c b/subversion/libsvn_subr/config_auth.c
index d53403c..091e4e8 100644
--- a/subversion/libsvn_subr/config_auth.c
+++ b/subversion/libsvn_subr/config_auth.c
@@ -173,12 +173,6 @@ svn_config_walk_auth_data(const char *config_dir,
NULL
};
- if (! config_dir)
- {
- /* Can't locate the cache to clear */
- return SVN_NO_ERROR;
- }
-
iterpool = svn_pool_create(scratch_pool);
for (i = 0; cred_kinds[i]; i++)
{
diff --git a/subversion/libsvn_subr/deprecated.c b/subversion/libsvn_subr/deprecated.c
index 378b3f8..93bd89d 100644
--- a/subversion/libsvn_subr/deprecated.c
+++ b/subversion/libsvn_subr/deprecated.c
@@ -47,6 +47,7 @@
#include "opt.h"
#include "private/svn_opt_private.h"
#include "private/svn_mergeinfo_private.h"
+#include "private/svn_subr_private.h"
#include "svn_private_config.h"
@@ -1301,4 +1302,10 @@ svn_subst_build_keywords(svn_subst_keywords_t *kw,
return SVN_NO_ERROR;
}
-
+/*** From version.c ***/
+svn_error_t *
+svn_ver_check_list(const svn_version_t *my_version,
+ const svn_version_checklist_t *checklist)
+{
+ return svn_ver_check_list2(my_version, checklist, svn_ver_compatible);
+}
diff --git a/subversion/libsvn_subr/dirent_uri.c b/subversion/libsvn_subr/dirent_uri.c
index 2b51e7a..4801f8c 100644
--- a/subversion/libsvn_subr/dirent_uri.c
+++ b/subversion/libsvn_subr/dirent_uri.c
@@ -1857,6 +1857,9 @@ svn_uri_is_canonical(const char *uri, apr_pool_t *scratch_pool)
#endif /* SVN_USE_DOS_PATHS */
/* Now validate the rest of the URI. */
+ seg = ptr;
+ while (*ptr && (*ptr != '/'))
+ ptr++;
while(1)
{
apr_size_t seglen = ptr - seg;
@@ -1875,9 +1878,8 @@ svn_uri_is_canonical(const char *uri, apr_pool_t *scratch_pool)
if (*ptr == '/')
ptr++;
- seg = ptr;
-
+ seg = ptr;
while (*ptr && (*ptr != '/'))
ptr++;
}
diff --git a/subversion/libsvn_subr/internal_statements.h b/subversion/libsvn_subr/internal_statements.h
index dd81d9f..f24ca05 100644
--- a/subversion/libsvn_subr/internal_statements.h
+++ b/subversion/libsvn_subr/internal_statements.h
@@ -1,4 +1,4 @@
-/* This file is automatically generated from internal_statements.sql and .dist_sandbox/subversion-1.8.1/subversion/libsvn_subr/token-map.h.
+/* This file is automatically generated from internal_statements.sql and .dist_sandbox/subversion-1.8.4/subversion/libsvn_subr/token-map.h.
* Do not edit this file -- edit the source and rerun gen-make.py */
#define STMT_INTERNAL_SAVEPOINT_SVN 0
diff --git a/subversion/libsvn_subr/io.c b/subversion/libsvn_subr/io.c
index d318194..385ae37 100644
--- a/subversion/libsvn_subr/io.c
+++ b/subversion/libsvn_subr/io.c
@@ -3306,7 +3306,7 @@ do_io_file_wrapper_cleanup(apr_file_t *file, apr_status_t status,
/* ### Issue #3014: Return a specific error for broken pipes,
* ### with a single element in the error chain. */
- if (APR_STATUS_IS_EPIPE(status))
+ if (SVN__APR_STATUS_IS_EPIPE(status))
return svn_error_create(SVN_ERR_IO_PIPE_WRITE_ERROR, NULL, NULL);
if (name)
diff --git a/subversion/libsvn_subr/sysinfo.c b/subversion/libsvn_subr/sysinfo.c
index 455dca4..7c37822 100644
--- a/subversion/libsvn_subr/sysinfo.c
+++ b/subversion/libsvn_subr/sysinfo.c
@@ -546,7 +546,7 @@ linux_release_name(apr_pool_t *pool)
#ifdef WIN32
typedef DWORD (WINAPI *FNGETNATIVESYSTEMINFO)(LPSYSTEM_INFO);
-typedef BOOL (WINAPI *FNENUMPROCESSMODULES) (HANDLE, HMODULE, DWORD, LPDWORD);
+typedef BOOL (WINAPI *FNENUMPROCESSMODULES) (HANDLE, HMODULE*, DWORD, LPDWORD);
/* Get system and version info, and try to tell the difference
between the native system type and the runtime environment of the
@@ -763,16 +763,36 @@ win32_release_name(apr_pool_t *pool)
static HMODULE *
enum_loaded_modules(apr_pool_t *pool)
{
+ HMODULE psapi_dll = 0;
HANDLE current = GetCurrentProcess();
HMODULE dummy[1];
HMODULE *handles;
DWORD size;
+ FNENUMPROCESSMODULES EnumProcessModules_;
- if (!EnumProcessModules(current, dummy, sizeof(dummy), &size))
+ psapi_dll = GetModuleHandleA("psapi.dll");
+
+ if (!psapi_dll)
+ {
+ /* Load and never unload, just like static linking */
+ psapi_dll = LoadLibraryA("psapi.dll");
+ }
+
+ if (!psapi_dll)
+ return NULL;
+
+ EnumProcessModules_ = (FNENUMPROCESSMODULES)
+ GetProcAddress(psapi_dll, "EnumProcessModules");
+
+ /* Before Windows XP psapi was an optional module */
+ if (! EnumProcessModules_)
+ return NULL;
+
+ if (!EnumProcessModules_(current, dummy, sizeof(dummy), &size))
return NULL;
handles = apr_palloc(pool, size + sizeof *handles);
- if (!EnumProcessModules(current, handles, size, &size))
+ if (! EnumProcessModules_(current, handles, size, &size))
return NULL;
handles[size / sizeof *handles] = NULL;
return handles;
diff --git a/subversion/libsvn_subr/utf.c b/subversion/libsvn_subr/utf.c
index 535e3da..4f9102d 100644
--- a/subversion/libsvn_subr/utf.c
+++ b/subversion/libsvn_subr/utf.c
@@ -212,6 +212,7 @@ xlate_alloc_handle(xlate_handle_node_t **ret,
{
apr_status_t apr_err;
apr_xlate_t *handle;
+ const char *name;
/* The error handling doesn't support the following cases, since we don't
use them currently. Catch this here. */
@@ -224,8 +225,10 @@ xlate_alloc_handle(xlate_handle_node_t **ret,
#if defined(WIN32)
apr_err = svn_subr__win32_xlate_open((win32_xlate_t **)&handle, topage,
frompage, pool);
+ name = "win32-xlate: ";
#else
apr_err = apr_xlate_open(&handle, topage, frompage, pool);
+ name = "APR: ";
#endif
if (APR_STATUS_IS_EINVAL(apr_err) || APR_STATUS_IS_ENOTIMPL(apr_err))
@@ -254,9 +257,9 @@ xlate_alloc_handle(xlate_handle_node_t **ret,
later. APR_STRERR will be in the local encoding, not in UTF-8, though.
*/
svn_strerror(apr_err, apr_strerr, sizeof(apr_strerr));
- return svn_error_create(apr_err,
- svn_error_create(apr_err, NULL, apr_strerr),
- errstr);
+ return svn_error_createf(SVN_ERR_PLUGIN_LOAD_FAILURE,
+ svn_error_create(apr_err, NULL, apr_strerr),
+ "%s%s", name, errstr);
}
/* Allocate and initialize the node. */
diff --git a/subversion/libsvn_subr/version.c b/subversion/libsvn_subr/version.c
index ad2a270..03dc83b 100644
--- a/subversion/libsvn_subr/version.c
+++ b/subversion/libsvn_subr/version.c
@@ -75,8 +75,10 @@ svn_boolean_t svn_ver_equal(const svn_version_t *my_version,
svn_error_t *
-svn_ver_check_list(const svn_version_t *my_version,
- const svn_version_checklist_t *checklist)
+svn_ver__check_list2(const svn_version_t *my_version,
+ const svn_version_checklist_t *checklist,
+ svn_boolean_t (*comparator)(const svn_version_t *,
+ const svn_version_t *))
{
svn_error_t *err = SVN_NO_ERROR;
int i;
@@ -84,12 +86,17 @@ svn_ver_check_list(const svn_version_t *my_version,
for (i = 0; checklist[i].label != NULL; ++i)
{
const svn_version_t *lib_version = checklist[i].version_query();
- if (!svn_ver_compatible(my_version, lib_version))
+ if (!comparator(my_version, lib_version))
err = svn_error_createf(SVN_ERR_VERSION_MISMATCH, err,
- _("Version mismatch in '%s':"
+ _("Version mismatch in '%s'%s:"
" found %d.%d.%d%s,"
" expected %d.%d.%d%s"),
checklist[i].label,
+ comparator == svn_ver_equal
+ ? _(" (expecting equality)")
+ : comparator == svn_ver_compatible
+ ? _(" (expecting compatibility)")
+ : "",
lib_version->major, lib_version->minor,
lib_version->patch, lib_version->tag,
my_version->major, my_version->minor,
diff --git a/subversion/libsvn_subr/win32_crashrpt.c b/subversion/libsvn_subr/win32_crashrpt.c
index 6becc96..4b665c1 100644
--- a/subversion/libsvn_subr/win32_crashrpt.c
+++ b/subversion/libsvn_subr/win32_crashrpt.c
@@ -427,13 +427,15 @@ write_var_values(PSYMBOL_INFO sym_info, ULONG sym_size, void *baton)
format_value(value_str, sym_info->ModBase, sym_info->TypeIndex,
(void *)var_data);
- fprintf(log_file, "%s=%s", sym_info->Name, value_str);
+ fprintf(log_file, "%.*s=%s", (int)sym_info->NameLen, sym_info->Name,
+ value_str);
}
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", sym_info->Name, value_str);
+ fprintf(log_file, " %.*s = %s\n", (int)sym_info->NameLen,
+ sym_info->Name, value_str);
}
return TRUE;
@@ -466,8 +468,10 @@ write_function_detail(STACKFRAME64 stack_frame, int nr_of_frame, FILE *log_file)
if (SymFromAddr_(proc, stack_frame.AddrPC.Offset, &func_disp, pIHS))
{
fprintf(log_file,
- "#%d 0x%08I64x in %.200s(",
- nr_of_frame, stack_frame.AddrPC.Offset, pIHS->Name);
+ "#%d 0x%08I64x in %.*s(",
+ nr_of_frame, stack_frame.AddrPC.Offset,
+ pIHS->NameLen > 200 ? 200 : (int)pIHS->NameLen,
+ pIHS->Name);
/* restrict symbol enumeration to this frame only */
ih_stack_frame.InstructionOffset = stack_frame.AddrPC.Offset;
OpenPOWER on IntegriCloud