Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: components/webcrypto/algorithms/aes_cbc.cc

Issue 2528243002: Fix silent truncations when extracting values from CheckedNumeric (Closed)
Patch Set: compile fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/utility/safe_browsing/mac/udif.cc ('k') | components/webcrypto/algorithms/aes_ctr.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/webcrypto/algorithms/aes_cbc.cc
diff --git a/components/webcrypto/algorithms/aes_cbc.cc b/components/webcrypto/algorithms/aes_cbc.cc
index c9e941aa7ee92f636d0dc84e5e4e8c0853fb35aa..678aa5ac2cefa6a2f162c77f1a5b13144440c220 100644
--- a/components/webcrypto/algorithms/aes_cbc.cc
+++ b/components/webcrypto/algorithms/aes_cbc.cc
@@ -1,3 +1,4 @@
+
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -55,7 +56,8 @@ Status AesCbcEncryptDecrypt(EncryptOrDecrypt cipher_operation,
if (!output_max_len.IsValid())
return Status::ErrorDataTooLarge();
- const unsigned remainder = output_max_len.ValueOrDie() % AES_BLOCK_SIZE;
+ const unsigned remainder =
+ base::ValueOrDieForType<unsigned>(output_max_len % AES_BLOCK_SIZE);
if (remainder != 0)
output_max_len += AES_BLOCK_SIZE - remainder;
if (!output_max_len.IsValid())
@@ -71,7 +73,7 @@ Status AesCbcEncryptDecrypt(EncryptOrDecrypt cipher_operation,
return Status::OperationError();
}
- buffer->resize(output_max_len.ValueOrDie());
+ buffer->resize(base::ValueOrDieForType<size_t>(output_max_len));
int output_len = 0;
if (!EVP_CipherUpdate(context.get(), buffer->data(), &output_len,
« no previous file with comments | « chrome/utility/safe_browsing/mac/udif.cc ('k') | components/webcrypto/algorithms/aes_ctr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698