Author: rinrab
Date: Sun Mar 15 18:50:57 2026
New Revision: 1932307
Log:
Implement properly-sized updates when computing contextless checksum via
Windows BCrypt.
* subversion/libsvn_subr/checksum_bcrypt.c
(bcrypt_checksum): Update declaration so the function requires a char*
instead of void* and add a loop to process as blocks of ULONG_MAX. Note: we
cannot use already existing bcrypt_ctx_update because we don't have
a bcrypt_ctx_t in this context - this just a different nature where all
allocation should be done on stack.
Modified:
subversion/trunk/subversion/libsvn_subr/checksum_bcrypt.c
Modified: subversion/trunk/subversion/libsvn_subr/checksum_bcrypt.c
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/checksum_bcrypt.c Sun Mar 15 18:45:02 2026 (r1932306)
+++ subversion/trunk/subversion/libsvn_subr/checksum_bcrypt.c Sun Mar 15 18:50:57 2026 (r1932307)
@@ -172,14 +172,12 @@ bcrypt_ctx_reset(algorithm_state_t *algo
static svn_error_t *
bcrypt_checksum(algorithm_state_t *algorithm,
unsigned char *digest,
- const void *data,
+ const char *data,
apr_size_t len)
{
BCRYPT_HANDLE handle;
void *object_buf;
- SVN_ERR_ASSERT(len <= ULONG_MAX);
-
SVN_ERR(svn_atomic__init_once(&algorithm->initialized, algorithm_init,
algorithm, NULL));
@@ -193,10 +191,22 @@ bcrypt_checksum(algorithm_state_t *algor
/* cbSecret */ 0,
/* dwFlags */ 0)));
- SVN_ERR(handle_error(BCryptHashData(handle,
- (PUCHAR) data,
- (ULONG) len,
- /* dwFlags */ 0)));
+ while (len > 0)
+ {
+ ULONG block;
+
+ if (len < ULONG_MAX)
+ block = (ULONG)len;
+ else
+ block = UINT_MAX;
+
+ SVN_ERR(handle_error(BCryptHashData(handle,
+ (PUCHAR) data, block,
+ /* dwFlags */ 0)));
+
+ len -= block;
+ data += block;
+ }
SVN_ERR(handle_error(BCryptFinishHash(handle,
(PUCHAR) digest,
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.