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

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

Issue 2528243002: Fix silent truncations when extracting values from CheckedNumeric (Closed)
Patch Set: compile cleanup and fix Created 4 years, 1 month 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
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..a31882964e9862ef1ddddd1b112f297c064302b6 100644
--- a/components/webcrypto/algorithms/aes_cbc.cc
+++ b/components/webcrypto/algorithms/aes_cbc.cc
@@ -55,7 +55,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 =
+ (output_max_len % AES_BLOCK_SIZE).template ValueOrDie<unsigned>();
if (remainder != 0)
Tom Sepez 2016/11/29 20:06:26 I'm not grokking this. Can you explain? May be t
jschuh 2016/11/29 21:04:47 It's the template disambiguator for dependent name
jschuh 2016/11/30 23:38:52 I added some helpers and am using those at the cal
output_max_len += AES_BLOCK_SIZE - remainder;
if (!output_max_len.IsValid())
@@ -71,7 +72,7 @@ Status AesCbcEncryptDecrypt(EncryptOrDecrypt cipher_operation,
return Status::OperationError();
}
- buffer->resize(output_max_len.ValueOrDie());
+ buffer->resize(output_max_len.template ValueOrDie<size_t>());
int output_len = 0;
if (!EVP_CipherUpdate(context.get(), buffer->data(), &output_len,

Powered by Google App Engine
This is Rietveld 408576698