ruby-changes:23503
From: nobu <ko1@a...>
Date: Mon, 7 May 2012 10:28:07 +0900 (JST)
Subject: [ruby-changes:23503] nobu:r35554 (trunk): rmd160.c: fix for huge data
nobu 2012-05-07 10:27:59 +0900 (Mon, 07 May 2012) New Revision: 35554 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35554 Log: rmd160.c: fix for huge data * ext/digest/rmd160/rmd160.c (RMD160_Update): fix for huge data. Modified files: trunk/ChangeLog trunk/ext/digest/rmd160/rmd160.c Index: ChangeLog =================================================================== --- ChangeLog (revision 35553) +++ ChangeLog (revision 35554) @@ -1,3 +1,7 @@ +Mon May 7 10:27:56 2012 Nobuyoshi Nakada <nobu@r...> + + * ext/digest/rmd160/rmd160.c (RMD160_Update): fix for huge data. + Mon May 7 10:23:04 2012 Nobuyoshi Nakada <nobu@r...> * test/fileutils/fileasserts.rb: use assert_equal, assert_match, and so on. Index: ext/digest/rmd160/rmd160.c =================================================================== --- ext/digest/rmd160/rmd160.c (revision 35553) +++ ext/digest/rmd160/rmd160.c (revision 35554) @@ -362,16 +362,20 @@ _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 @@ /* * 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); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/