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 2015/11/14 15:42:18 UTC

svn commit: r1714339 - /subversion/trunk/subversion/libsvn_ra_svn/marshal.c

Author: stefan2
Date: Sat Nov 14 14:42:17 2015
New Revision: 1714339

URL: http://svn.apache.org/viewvc?rev=1714339&view=rev
Log:
For ra-svn client requests that exceed the newly introduced limit,
usually there is only one huge string component, e.g. some large
property value, that causes the problem.  Detect them early such
that we might not even need to transfer the whole data up to the
limit before giving up. 

* subversion/libsvn_ra_svn/marshal.c
  (read_string): Exit as soon as we know we will exceed the configured
                 size limit.

Modified:
    subversion/trunk/subversion/libsvn_ra_svn/marshal.c

Modified: subversion/trunk/subversion/libsvn_ra_svn/marshal.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/marshal.c?rev=1714339&r1=1714338&r2=1714339&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/marshal.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/marshal.c Sat Nov 14 14:42:17 2015
@@ -1204,6 +1204,16 @@ static svn_error_t *read_string(svn_ra_s
     }
   else
     {
+      svn_stringbuf_t *stringbuf;
+
+      /* Don't even attempt to read anything that exceeds the I/O limit.
+       * So, we can terminate the transfer at an early point, saving
+       * everybody's time and resources. */
+      if (conn->max_in && (conn->max_in < len64))
+        return svn_error_create(SVN_ERR_RA_SVN_REQUEST_SIZE, NULL,
+                                "The client request size exceeds the "
+                                "configured limit");
+
       /* Read the string in chunks.  The chunk size is large enough to avoid
        * re-allocation in typical cases, and small enough to ensure we do
        * not pre-allocate an unreasonable amount of memory if (perhaps due
@@ -1212,7 +1222,7 @@ static svn_error_t *read_string(svn_ra_s
        * start small and wait for all that data to actually show up.  This
        * does not fully prevent DOS attacks but makes them harder (you have
        * to actually send gigabytes of data). */
-      svn_stringbuf_t *stringbuf = svn_stringbuf_create_empty(pool);
+      stringbuf = svn_stringbuf_create_empty(pool);
 
       /* Read string data directly into the string structure.
        * Do it iteratively.  */