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 2013/05/16 22:27:17 UTC

svn commit: r1483545 - in /subversion/trunk/subversion: libsvn_subr/types.c tests/libsvn_subr/revision-test.c

Author: stefan2
Date: Thu May 16 20:27:17 2013
New Revision: 1483545

URL: http://svn.apache.org/r1483545
Log:
Follow-up to r1483535:  In case of overflow, return the start pointer
in *ENDPTR.  Also, fix the overflow condition.

Extend the test cases to cover the range checking corner cases.

* subversion/libsvn_subr/types.c
  (svn_revnum_parse): fix overflow detection and error behavior

* subversion/tests/libsvn_subr/revision-test.c
  (test_revnum_parse): add range check corner cases

Modified:
    subversion/trunk/subversion/libsvn_subr/types.c
    subversion/trunk/subversion/tests/libsvn_subr/revision-test.c

Modified: subversion/trunk/subversion/libsvn_subr/types.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/types.c?rev=1483545&r1=1483544&r2=1483545&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/types.c (original)
+++ subversion/trunk/subversion/libsvn_subr/types.c Thu May 16 20:27:17 2013
@@ -42,7 +42,7 @@ svn_revnum_parse(svn_revnum_t *rev,
   svn_revnum_t result = (svn_revnum_t)svn__strtoul(str, &end);
 
   if (endptr)
-    *endptr = end;
+    *endptr = str;
 
   if (str == end)
     return svn_error_createf
@@ -62,12 +62,15 @@ svn_revnum_parse(svn_revnum_t *rev,
                   _("Revision number longer than 10 digits '%s'"), str);
         
       /* we support 32 bit revision numbers only. check for overflows */
-      if (result < 1000000000 || result > APR_INT32_MAX)
+      if (*str > '2' || (apr_uint32_t)result > APR_INT32_MAX)
         return svn_error_createf
                   (SVN_ERR_REVNUM_PARSE_FAILURE, NULL,
                   _("Revision number too large or not normalized '%s'"), str);
     }
   
+  if (endptr)
+    *endptr = end;
+
   *rev = result;
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/tests/libsvn_subr/revision-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/revision-test.c?rev=1483545&r1=1483544&r2=1483545&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/revision-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/revision-test.c Thu May 16 20:27:17 2013
@@ -34,6 +34,12 @@ test_revnum_parse(apr_pool_t *pool)
     "",
     "abc",
     "-456",
+    "2147483648",
+    "4294967295",
+    "4300000000",
+    "00000000001",
+    "21474836470",
+    "999999999999999999999999",
     NULL
   };
 
@@ -41,6 +47,8 @@ test_revnum_parse(apr_pool_t *pool)
     "0",
     "12345",
     "12345ABC",
+    "0000000001",
+    "2147483647x",
     NULL
   };