* 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
This commit is contained in:
nobu 2012-05-07 01:27:59 +00:00
Родитель 298258891d
Коммит cc3f33073d
2 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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);
}
}