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 2012/06/12 13:48:29 UTC
svn commit: r1349277 - in /subversion/trunk/subversion:
include/svn_error_codes.h libsvn_subr/cache-memcache.c
Author: stefan2
Date: Tue Jun 12 11:48:29 2012
New Revision: 1349277
URL: http://svn.apache.org/viewvc?rev=1349277&view=rev
Log:
Fixing an int -> 16 bit int assignment warning. While at it, handle the
pathological case of an unreasonably large number of memcached configs.
* include/svn_error_codes.h
(SVN_ERR_TOO_MANY_MEMCACHED_SERVERS): declare new error code
* libsvn_subr/cache-memcache.c
(svn_cache__make_memcache_from_config): check for overflow before casting
the server count to int16
Modified:
subversion/trunk/subversion/include/svn_error_codes.h
subversion/trunk/subversion/libsvn_subr/cache-memcache.c
Modified: subversion/trunk/subversion/include/svn_error_codes.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_error_codes.h?rev=1349277&r1=1349276&r2=1349277&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_error_codes.h (original)
+++ subversion/trunk/subversion/include/svn_error_codes.h Tue Jun 12 11:48:29 2012
@@ -1400,6 +1400,11 @@ SVN_ERROR_START
SVN_ERR_MISC_CATEGORY_START + 35,
"Constraint error in SQLite db")
+ /** @since New in 1.8. */
+ SVN_ERRDEF(SVN_ERR_TOO_MANY_MEMCACHED_SERVERS,
+ SVN_ERR_MISC_CATEGORY_START + 36,
+ "too many memcached servers configured")
+
/* command-line client errors */
SVN_ERRDEF(SVN_ERR_CL_ARG_PARSING_ERROR,
Modified: subversion/trunk/subversion/libsvn_subr/cache-memcache.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cache-memcache.c?rev=1349277&r1=1349276&r2=1349277&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache-memcache.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache-memcache.c Tue Jun 12 11:48:29 2012
@@ -527,7 +527,7 @@ svn_cache__make_memcache_from_config(svn
svn_config_t *config,
apr_pool_t *pool)
{
- apr_uint16_t server_count;
+ int server_count;
apr_pool_t *subpool = svn_pool_create(pool);
server_count =
@@ -542,12 +542,15 @@ svn_cache__make_memcache_from_config(svn
return SVN_NO_ERROR;
}
+ if (server_count > APR_INT16_MAX)
+ return svn_error_create(SVN_ERR_TOO_MANY_MEMCACHED_SERVERS, NULL, NULL);
+
#ifdef SVN_HAVE_MEMCACHE
{
struct ams_baton b;
svn_memcache_t *memcache = apr_pcalloc(pool, sizeof(*memcache));
apr_status_t apr_err = apr_memcache_create(pool,
- server_count,
+ (apr_uint16_t)server_count,
0, /* flags */
&(memcache->c));
if (apr_err != APR_SUCCESS)