aboutsummaryrefslogtreecommitdiffstats
path: root/ext/digest
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-07 01:27:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-07 01:27:59 +0000
commitcc3f33073dc1c475f59a14753a4203c193f9fbfc (patch)
treefa914c99c9d157e9ab7a01ffde68845e7e942613 /ext/digest
parent298258891d2f8a80f8d1eac193c6609a256a3cf0 (diff)
downloadruby-cc3f33073dc1c475f59a14753a4203c193f9fbfc.tar.gz
rmd160.c: fix for huge data
* ext/digest/rmd160/rmd160.c (RMD160_Update): fix for huge data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest')
-rw-r--r--ext/digest/rmd160/rmd160.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/digest/rmd160/rmd160.c b/ext/digest/rmd160/rmd160.c
index 88918728cd..bac77833b1 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);
}
}