Author: stefan2
Date: Mon Aug 18 16:38:04 2014
New Revision: 1618662
URL: http://svn.apache.org/r1618662
Log:
* subversion/libsvn_fs_fs/id.c
(locale_independent_strtol): Complete and explain the overflow check.
Modified:
subversion/trunk/subversion/libsvn_fs_fs/id.c
Modified: subversion/trunk/subversion/libsvn_fs_fs/id.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/id.c?rev=1618662&r1=1618661&r2=1618662&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/id.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/id.c Mon Aug 18 16:38:04 2014
@@ -74,9 +74,17 @@ locale_independent_strtol(long *result_p
if (c > 9)
break;
+ /* Overflow check. Passing this, NEXT can be no more than ULONG_MAX+9
+ * before being truncated to ULONG but it still covers 0 .. ULONG_MAX.
+ */
+ if (result > ULONG_MAX / 10)
+ return FALSE;
+
next = result * 10 + c;
- /* Overflow check. */
+ /* Overflow check. In case of an overflow, NEXT is 0..9.
+ * In the non-overflow case, RESULT is either >= 10 or RESULT and NEXT
+ * are both 0. */
if (next < result)
return FALSE;