Author: rinrab
Date: Sat Jan 17 17:11:02 2026
New Revision: 1931389
Log:
Handle SHA1 checksum update with APR backend (whose update consumes size as
`unsigned int`, not a size_t) if a buffer with a size more than the limit of
unsigned integer by iterating trough data via blocks and invoking the backend
multiple times.
* subversion/libsvn_subr/checksum_apr.c
(sha1_update): New helper function to provide "proper" update.
(svn_checksum__sha1, svn_checksum__sha1_ctx_update): Call local sha1_update()
and remove assertion.
Modified:
subversion/trunk/subversion/libsvn_subr/checksum_apr.c
Modified: subversion/trunk/subversion/libsvn_subr/checksum_apr.c
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/checksum_apr.c Sat Jan 17 13:08:58 2026 (r1931388)
+++ subversion/trunk/subversion/libsvn_subr/checksum_apr.c Sat Jan 17 17:11:02 2026 (r1931389)
@@ -85,6 +85,27 @@ svn_checksum__md5_ctx_final(unsigned cha
/*** SHA1 checksum ***/
+static void
+sha1_update(apr_sha1_ctx_t *ctx,
+ const void *data,
+ apr_size_t len)
+{
+ while (len > 0)
+ {
+ unsigned int block;
+
+ if (len < UINT_MAX)
+ block = len;
+ else
+ block = UINT_MAX;
+
+ apr_sha1_update(ctx, data, block);
+
+ len -= block;
+ data += block;
+ }
+}
+
svn_error_t *
svn_checksum__sha1(unsigned char *digest,
const void *data,
@@ -92,12 +113,10 @@ svn_checksum__sha1(unsigned char *digest
{
apr_sha1_ctx_t sha1_ctx;
- /* Do not blindly truncate the data length. */
- SVN_ERR_ASSERT(len < UINT_MAX);
-
apr_sha1_init(&sha1_ctx);
- apr_sha1_update(&sha1_ctx, data, (unsigned int)len);
+ sha1_update(&sha1_ctx, data, len);
apr_sha1_final(digest, &sha1_ctx);
+
return SVN_NO_ERROR;
}
@@ -127,9 +146,7 @@ svn_checksum__sha1_ctx_update(svn_checks
const void *data,
apr_size_t len)
{
- /* Do not blindly truncate the data length. */
- SVN_ERR_ASSERT(len < UINT_MAX);
- apr_sha1_update(&ctx->apr_ctx, data, (unsigned int)len);
+ sha1_update(&ctx->apr_ctx, data, len);
return SVN_NO_ERROR;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.