| Index: net/base/ssl_false_start_blacklist.h
|
| diff --git a/net/base/ssl_false_start_blacklist.h b/net/base/ssl_false_start_blacklist.h
|
| index 17596308d99bd155a225e7afab2a45ec9d1bf447..a32fb28904735e4fcde2f034ff48f0327551c9eb 100644
|
| --- a/net/base/ssl_false_start_blacklist.h
|
| +++ b/net/base/ssl_false_start_blacklist.h
|
| @@ -5,6 +5,8 @@
|
| #ifndef NET_BASE_SSL_FALSE_START_BLACKLIST_H_
|
| #define NET_BASE_SSL_FALSE_START_BLACKLIST_H_
|
|
|
| +#include <string>
|
| +
|
| #include "base/basictypes.h"
|
| #include "net/base/net_api.h"
|
|
|
| @@ -35,20 +37,27 @@ class SSLFalseStartBlacklist {
|
| return hash;
|
| }
|
|
|
| - // LastTwoLabels returns a pointer within |host| to the last two labels of
|
| - // |host|. For example, if |host| is "a.b.c.d" then LastTwoLabels will return
|
| - // "c.d".
|
| + // LastTwoLabels returns the last two labels of |host|. For example, if
|
| + // |host| is "a.b.c.d" then LastTwoLabels will return "c.d".
|
| // host: a DNS name in dotted form.
|
| - // returns: NULL on error, otherwise a pointer inside |host|.
|
| - static const char* LastTwoLabels(const char* host) {
|
| + // returns: empty string on error, otherwise the last two labels.
|
| + static std::string LastTwoLabels(const char* host) {
|
| // See comment in |Hash| for why this function is inline.
|
| const size_t len = strlen(host);
|
| if (len == 0)
|
| - return NULL;
|
| + return std::string();
|
|
|
| unsigned dots_found = 0;
|
| size_t i;
|
| +
|
| + // Remove trailing dots.
|
| for (i = len - 1; i < len; i--) {
|
| + if (host[i] != '.')
|
| + break;
|
| + }
|
| + const size_t end = i;
|
| +
|
| + for (; i < len; i--) {
|
| if (host[i] == '.') {
|
| dots_found++;
|
| if (dots_found == 2) {
|
| @@ -57,18 +66,18 @@ class SSLFalseStartBlacklist {
|
| }
|
| }
|
| }
|
| -
|
| if (i > len)
|
| i = 0;
|
|
|
| - if (dots_found == 0)
|
| - return NULL; // no names with less than two labels are in the blacklist.
|
| - if (dots_found == 1) {
|
| + if (dots_found == 0) {
|
| + // no names with less than two labels are in the blacklist.
|
| + return std::string();
|
| + } else if (dots_found == 1) {
|
| if (host[0] == '.')
|
| - return NULL; // ditto
|
| + return std::string(); // ditto
|
| }
|
|
|
| - return &host[i];
|
| + return std::string(&host[i], end - i + 1);
|
| }
|
|
|
| // This is the number of buckets in the blacklist hash table. (Must be a
|
|
|