Index: crypto/ghash.cc |
diff --git a/crypto/ghash.cc b/crypto/ghash.cc |
index 939dd0b86bcdbe27d0915a8f03abb889dc2c445b..5b28c442b89fe36878873ea45297cce8eba86534 100644 |
--- a/crypto/ghash.cc |
+++ b/crypto/ghash.cc |
@@ -229,7 +229,7 @@ void GaloisHash::UpdateBlocks(const uint8* bytes, size_t num_blocks) { |
void GaloisHash::Update(const uint8* data, size_t length) { |
if (buf_used_ > 0) { |
- const size_t n = std::min(length, buf_used_); |
+ const size_t n = std::min(length, sizeof(buf_) - buf_used_); |
memcpy(&buf_[buf_used_], data, n); |
buf_used_ += n; |
length -= n; |