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

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: fix testing order for openssl 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
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 =

Powered by Google App Engine
This is Rietveld 408576698