You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by sv...@apache.org on 2013/06/19 06:00:34 UTC

svn commit: r1494436 - in /subversion/branches/1.8.x: ./ STATUS subversion/libsvn_subr/io.c subversion/tests/libsvn_subr/io-test.c

Author: svn-role
Date: Wed Jun 19 04:00:33 2013
New Revision: 1494436

URL: http://svn.apache.org/r1494436
Log:
Merge r1492145 from trunk:

 * r1492145
   Properly handle a corner case in svn_io_read_length_line().
   Justification:
     Don't get in an endless loop when repos/db/uuid contains a \r\n instead
     of a \n. (Some testcode of one user got in this case by applying a hack
     and it worked in 1.7)
   Votes:
     +1: rhuijben, ivan, stefan2

Modified:
    subversion/branches/1.8.x/   (props changed)
    subversion/branches/1.8.x/STATUS
    subversion/branches/1.8.x/subversion/libsvn_subr/io.c
    subversion/branches/1.8.x/subversion/tests/libsvn_subr/io-test.c

Propchange: subversion/branches/1.8.x/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1492145

Modified: subversion/branches/1.8.x/STATUS
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x/STATUS?rev=1494436&r1=1494435&r2=1494436&view=diff
==============================================================================
--- subversion/branches/1.8.x/STATUS (original)
+++ subversion/branches/1.8.x/STATUS Wed Jun 19 04:00:33 2013
@@ -223,15 +223,6 @@ Veto-blocked changes:
 Approved changes:
 =================
 
- * r1492145
-   Properly handle a corner case in svn_io_read_length_line().
-   Justification:
-     Don't get in an endless loop when repos/db/uuid contains a \r\n instead
-     of a \n. (Some testcode of one user got in this case by applying a hack
-     and it worked in 1.7)
-   Votes:
-     +1: rhuijben, ivan, stefan2
-
  * r1491770
    Eliminate revprop buffer size limit.
    Justification:

Modified: subversion/branches/1.8.x/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x/subversion/libsvn_subr/io.c?rev=1494436&r1=1494435&r2=1494436&view=diff
==============================================================================
--- subversion/branches/1.8.x/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/1.8.x/subversion/libsvn_subr/io.c Wed Jun 19 04:00:33 2013
@@ -3533,6 +3533,9 @@ svn_io_read_length_line(apr_file_t *file
       apr_size_t bytes_read = 0;
       char *eol;
 
+      if (to_read == 0)
+        break;
+
       /* read data block (or just a part of it) */
       SVN_ERR(svn_io_file_read_full2(file, buf, to_read,
                                      &bytes_read, &eof, pool));

Modified: subversion/branches/1.8.x/subversion/tests/libsvn_subr/io-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x/subversion/tests/libsvn_subr/io-test.c?rev=1494436&r1=1494435&r2=1494436&view=diff
==============================================================================
--- subversion/branches/1.8.x/subversion/tests/libsvn_subr/io-test.c (original)
+++ subversion/branches/1.8.x/subversion/tests/libsvn_subr/io-test.c Wed Jun 19 04:00:33 2013
@@ -481,6 +481,31 @@ test_three_file_content_comparison(apr_p
   return err;
 }
 
+static svn_error_t *
+read_length_line_shouldnt_loop(apr_pool_t *pool)
+{
+  const char *tmp_dir;
+  const char *tmp_file;
+  char buffer[4];
+  apr_size_t buffer_limit = sizeof(buffer);
+  apr_file_t *f;
+
+  SVN_ERR(svn_dirent_get_absolute(&tmp_dir, "read_length_tmp", pool));
+  SVN_ERR(svn_io_remove_dir2(tmp_dir, TRUE, NULL, NULL, pool));
+  SVN_ERR(svn_io_make_dir_recursively(tmp_dir, pool));
+  svn_test_add_dir_cleanup(tmp_dir);
+
+  SVN_ERR(svn_io_write_unique(&tmp_file, tmp_dir, "1234\r\n", 6,
+                              svn_io_file_del_on_pool_cleanup, pool));
+
+  SVN_ERR(svn_io_file_open(&f, tmp_file, APR_READ, APR_OS_DEFAULT, pool));
+
+  SVN_TEST_ASSERT_ERROR(svn_io_read_length_line(f, buffer, &buffer_limit,
+                                                pool), SVN_ERR_MALFORMED_FILE);
+  SVN_TEST_ASSERT(buffer_limit == 4);
+
+  return SVN_NO_ERROR;
+}
 
 
 /* The test table.  */
@@ -496,5 +521,7 @@ struct svn_test_descriptor_t test_funcs[
                    "three file size comparison"),
     SVN_TEST_PASS2(test_three_file_content_comparison,
                    "three file content comparison"),
+    SVN_TEST_PASS2(read_length_line_shouldnt_loop,
+                   "svn_io_read_length_line() shouldn't loop"),
     SVN_TEST_NULL
   };