Author: ivan
Date: Wed Nov 4 10:12:17 2026
New Revision: 1940015
Log:
Fix problem svn_cstring_strtoui64() in error message for numbers larger than
APR_INT64_MAX.
Before this change the following code:
[[[
svn_cstring_strtoui64(&actual, "9223372036854775808", 0,
APR_UINT64_MAX, 10);
]]]
Generated error:
[[[
Number '9223372036854775808' is out of range '[0, 18446744073709551615]'
]]]
Which is doesn't make sense. The problem that svn_cstring_strtoui64()
currently uses apr_strtoi64() internally and cannot handle numbers larger than
APR_INT64_MAX.
After the change the error message will be:
[[[
Number '9223372036854775808' is out of range '[0, 9223372036854775807]'
]]]
* subversion/libsvn_subr/string.c
(svn_cstring_strtoui64): Limit MAXVAL to APR_INT64_MAX.
* subversion/tests/libsvn_subr/string-test.c
(test_svn_cstring_strtoui64): Update test expectations.
Modified:
subversion/trunk/subversion/libsvn_subr/string.c
subversion/trunk/subversion/tests/libsvn_subr/string-test.c
Modified: subversion/trunk/subversion/libsvn_subr/string.c
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/string.c Wed Nov 4 09:59:54
2026 (r1940014)
+++ subversion/trunk/subversion/libsvn_subr/string.c Wed Nov 4 10:12:17
2026 (r1940015)
@@ -1070,6 +1070,11 @@ svn_cstring_strtoui64(apr_uint64_t *n, c
/* ### We're throwing away half the number range here.
* ### APR needs a apr_strtoui64() function. */
+ if (maxval > APR_INT64_MAX)
+ {
+ maxval = APR_INT64_MAX;
+ }
+
val = apr_strtoi64(str, &endptr, base);
if (errno == EINVAL || endptr == str || str[0] == '\0' || *endptr != '\0')
return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
Modified: subversion/trunk/subversion/tests/libsvn_subr/string-test.c
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/string-test.c Wed Nov 4
09:59:54 2026 (r1940014)
+++ subversion/trunk/subversion/tests/libsvn_subr/string-test.c Wed Nov 4
10:12:17 2026 (r1940015)
@@ -1089,29 +1089,27 @@ test_svn_cstring_strtoui64(apr_pool_t *p
svn_cstring_strtoui64(&actual, "9223372036854775808", 0,
APR_UINT64_MAX, 10),
SVN_ERR_INCORRECT_PARAMS,
- "Number '9223372036854775808' is out of range '[0,
18446744073709551615]'");
+ "Number '9223372036854775808' is out of range '[0, 9223372036854775807]'");
/* 18446744073709551615 is APR_UINT64_MAX */
- /* ## The error message should be improved. */
SVN_TEST_ASSERT_ERROR_MSG(
svn_cstring_strtoui64(&actual, "18446744073709551615", 0,
APR_UINT64_MAX, 10),
SVN_ERR_INCORRECT_PARAMS,
- "Number '18446744073709551615' is out of range '[0,
18446744073709551615]'");
+ "Number '18446744073709551615' is out of range '[0,
9223372036854775807]'");
/* 18446744073709551615 is APR_UINT64_MAX */
- /* ## The error message should be improved. */
SVN_TEST_ASSERT_ERROR_MSG(svn_cstring_strtoui64(&actual,
"18446744073709551615", 0,
APR_UINT64_MAX, 10),
SVN_ERR_INCORRECT_PARAMS,
"Number '18446744073709551615' is out of range "
- "'[0, 18446744073709551615]'");
+ "'[0, 9223372036854775807]'");
SVN_TEST_ASSERT_ERROR_MSG(
svn_cstring_strtoui64(&actual, "-1", 0, APR_UINT64_MAX, 10),
SVN_ERR_INCORRECT_PARAMS,
- "Number '-1' is out of range '[0, 18446744073709551615]'");
+ "Number '-1' is out of range '[0, 9223372036854775807]'");
return SVN_NO_ERROR;
}