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

Unified Diff: content/child/webcrypto/nss/rsa_key_nss.cc

Issue 405693002: [refactor] Use base::CheckedNumeric<> in place of manual checks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: convert from unsigned int --> int Created 6 years, 5 months 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 | « content/child/webcrypto/nss/aes_kw_nss.cc ('k') | content/child/webcrypto/openssl/aes_cbc_openssl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/nss/rsa_key_nss.cc
diff --git a/content/child/webcrypto/nss/rsa_key_nss.cc b/content/child/webcrypto/nss/rsa_key_nss.cc
index 4ad79870710d24f83bdaf60dda99f2328e5f2bfb..75f380264e49856aaad012aab6a80203a5258233 100644
--- a/content/child/webcrypto/nss/rsa_key_nss.cc
+++ b/content/child/webcrypto/nss/rsa_key_nss.cc
@@ -5,6 +5,7 @@
#include "content/child/webcrypto/nss/rsa_key_nss.h"
#include "base/logging.h"
+#include "base/numerics/safe_math.h"
#include "content/child/webcrypto/crypto_data.h"
#include "content/child/webcrypto/jwk.h"
#include "content/child/webcrypto/nss/key_nss.h"
@@ -598,9 +599,10 @@ Status RsaHashedAlgorithm::GenerateKeyPair(
PK11RSAGenParams rsa_gen_params;
// keySizeInBits is a signed type, don't pass in a negative value.
- if (params->modulusLengthBits() > INT_MAX)
+ base::CheckedNumeric<int> signed_modulus(params->modulusLengthBits());
+ if (!signed_modulus.IsValid())
return Status::OperationError();
- rsa_gen_params.keySizeInBits = params->modulusLengthBits();
+ rsa_gen_params.keySizeInBits = signed_modulus.ValueOrDie();
rsa_gen_params.pe = public_exponent;
const CK_FLAGS operation_flags_mask =
« no previous file with comments | « content/child/webcrypto/nss/aes_kw_nss.cc ('k') | content/child/webcrypto/openssl/aes_cbc_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698