summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--ext/digest/rmd160/rmd160.c10
2 files changed, 11 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index b60ed8630c2..2b029da144d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon May 7 10:27:56 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/digest/rmd160/rmd160.c (RMD160_Update): fix for huge data.
+
Mon May 7 10:23:04 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/fileutils/fileasserts.rb: use assert_equal, assert_match, and so on.
diff --git a/ext/digest/rmd160/rmd160.c b/ext/digest/rmd160/rmd160.c
index 88918728cd5..bac77833b16 100644
--- a/ext/digest/rmd160/rmd160.c
+++ b/ext/digest/rmd160/rmd160.c
@@ -362,16 +362,20 @@ RMD160_Update(RMD160_CTX *context, const uint8_t *data, size_t nbytes)
_DIAGASSERT(data != NULL);
/* update length[] */
+#if SIZEOF_SIZE_T * CHAR_BIT > 32
+ context->length[1] += (uint32_t)((context->length[0] + nbytes) >> 32);
+#else
if (context->length[0] + nbytes < context->length[0])
context->length[1]++; /* overflow to msb of length */
- context->length[0] += nbytes;
+#endif
+ context->length[0] += (uint32_t)nbytes;
(void)memset(X, 0, sizeof(X));
if ( context->buflen + nbytes < 64 )
{
(void)memcpy(context->bbuffer + context->buflen, data, nbytes);
- context->buflen += nbytes;
+ context->buflen += (uint32_t)nbytes;
}
else
{
@@ -401,7 +405,7 @@ RMD160_Update(RMD160_CTX *context, const uint8_t *data, size_t nbytes)
/*
* Put last bytes from data into context's buffer
*/
- context->buflen = nbytes & 63;
+ context->buflen = (uint32_t)nbytes & 63;
memcpy(context->bbuffer, data + (64 * i) + ofs, context->buflen);
}
}