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

Unified Diff: components/proximity_auth/cryptauth/base64url.cc

Issue 1170363002: [Proximity auth] Disallow '+' and '/' in incoming base64-encoded strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a typo: 'palce' -> 'place' Created 5 years, 6 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 | « no previous file | components/proximity_auth/cryptauth/base64url_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/proximity_auth/cryptauth/base64url.cc
diff --git a/components/proximity_auth/cryptauth/base64url.cc b/components/proximity_auth/cryptauth/base64url.cc
index a38043fa0a3f53cf9f82d9cd930e8c42119c678f..d32f188b5741474eff783fe933719438fd944a16 100644
--- a/components/proximity_auth/cryptauth/base64url.cc
+++ b/components/proximity_auth/cryptauth/base64url.cc
@@ -18,6 +18,12 @@ void Base64UrlEncode(const std::string& decoded_input,
bool Base64UrlDecode(const std::string& encoded_input,
std::string* decoded_output) {
+ // Bail on malformed strings, which already contain a '+' or a '/'. All valid
+ // strings should escape these special characters as '-' and '_',
+ // respectively.
+ if (encoded_input.find_first_of("+/") != std::string::npos)
+ return false;
+
std::string adjusted_encoded_input = encoded_input;
base::ReplaceChars(adjusted_encoded_input, "-", "+", &adjusted_encoded_input);
base::ReplaceChars(adjusted_encoded_input, "_", "/", &adjusted_encoded_input);
« no previous file with comments | « no previous file | components/proximity_auth/cryptauth/base64url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698