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

Unified Diff: net/quic/crypto/source_address_token.cc

Issue 23464033: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix valgrind error Created 7 years, 3 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 | « net/quic/crypto/crypto_server_config.cc ('k') | net/quic/quic_ack_notifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/crypto/source_address_token.cc
diff --git a/net/quic/crypto/source_address_token.cc b/net/quic/crypto/source_address_token.cc
index d15afebf2a75557f30c6a9a3b724c7cfc1193c44..b095e762265f758aa2d2c9be40d5488fd8a255b5 100644
--- a/net/quic/crypto/source_address_token.cc
+++ b/net/quic/crypto/source_address_token.cc
@@ -21,24 +21,36 @@ SourceAddressToken::~SourceAddressToken() {
}
string SourceAddressToken::SerializeAsString() const {
- return ip_ + " " + base::Int64ToString(timestamp_);
+ string out;
+ out.push_back(ip_.size());
+ out.append(ip_);
+ string time_str = base::Int64ToString(timestamp_);
+ out.push_back(time_str.size());
+ out.append(time_str);
+ return out;
}
bool SourceAddressToken::ParseFromArray(const char* plaintext,
size_t plaintext_length) {
- string data(plaintext, plaintext_length);
- vector<string> results;
- base::SplitString(data, ' ', &results);
- if (results.size() < 2) {
+ if (plaintext_length == 0) {
+ return false;
+ }
+ size_t ip_len = plaintext[0];
+ if (plaintext_length <= 1 + ip_len) {
+ return false;
+ }
+ size_t time_len = plaintext[1 + ip_len];
+ if (plaintext_length != 1 + ip_len + 1 + time_len) {
return false;
}
+ string time_str(&plaintext[1 + ip_len + 1], time_len);
int64 timestamp;
- if (!base::StringToInt64(results[1], &timestamp)) {
+ if (!base::StringToInt64(time_str, &timestamp)) {
return false;
}
- ip_ = results[0];
+ ip_.assign(&plaintext[1], ip_len);
timestamp_ = timestamp;
return true;
}
« no previous file with comments | « net/quic/crypto/crypto_server_config.cc ('k') | net/quic/quic_ack_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698