|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80954 - branches/release/boost/uuid
From: atompkins_at_[hidden]
Date: 2012-10-11 11:30:20
Author: atompkins
Date: 2012-10-11 11:30:20 EDT (Thu, 11 Oct 2012)
New Revision: 80954
URL: http://svn.boost.org/trac/boost/changeset/80954
Log:
fixed bug in sha1.hpp for messages longer than 536,870,912 bytes, ticket #7128
Text files modified:
branches/release/boost/uuid/sha1.hpp | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
Modified: branches/release/boost/uuid/sha1.hpp
==============================================================================
--- branches/release/boost/uuid/sha1.hpp (original)
+++ branches/release/boost/uuid/sha1.hpp 2012-10-11 11:30:20 EDT (Thu, 11 Oct 2012)
@@ -90,10 +90,17 @@
{
process_byte_impl(byte);
- bit_count_low += 8;
- if (bit_count_low == 0) {
- ++bit_count_high;
- if (bit_count_high == 0) {
+ // size_t max value = 0xFFFFFFFF
+ //if (bit_count_low + 8 >= 0x100000000) { // would overflow
+ //if (bit_count_low >= 0x100000000-8) {
+ if (bit_count_low < 0xFFFFFFF8) {
+ bit_count_low += 8;
+ } else {
+ bit_count_low = 0;
+
+ if (bit_count_high <= 0xFFFFFFFE) {
+ ++bit_count_high;
+ } else {
BOOST_THROW_EXCEPTION(std::runtime_error("sha1 too many bytes"));
}
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk