OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/sdch_manager.h" | 5 #include "net/base/sdch_manager.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 std::string value(dictionary_text, value_start, line_end - value_start); | 369 std::string value(dictionary_text, value_start, line_end - value_start); |
370 name = base::ToLowerASCII(name); | 370 name = base::ToLowerASCII(name); |
371 if (name == "domain") { | 371 if (name == "domain") { |
372 domain = value; | 372 domain = value; |
373 } else if (name == "path") { | 373 } else if (name == "path") { |
374 path = value; | 374 path = value; |
375 } else if (name == "format-version") { | 375 } else if (name == "format-version") { |
376 if (value != "1.0") | 376 if (value != "1.0") |
377 return SDCH_DICTIONARY_UNSUPPORTED_VERSION; | 377 return SDCH_DICTIONARY_UNSUPPORTED_VERSION; |
378 } else if (name == "max-age") { | 378 } else if (name == "max-age") { |
379 int64_t seconds; | 379 // max-age must be a non-negative number. If it is very large saturate |
eroman
2016/04/11 19:36:37
Randy, what is the expected behavior here?
I wrot
| |
380 // TODO(eroman): crbug.com/596541 -- should not accept a leading +. | 380 // to 2^32 - 1. |
381 base::StringToInt64(value, &seconds); | 381 uint32_t seconds = std::numeric_limits<uint32_t>::max(); |
382 expiration = base::Time::Now() + base::TimeDelta::FromSeconds(seconds); | 382 ParseIntError parse_int_error; |
383 if (ParseUint32(value, &seconds, &parse_int_error) || | |
384 parse_int_error == ParseIntError::FAILED_OVERFLOW) { | |
385 expiration = | |
386 base::Time::Now() + base::TimeDelta::FromSeconds(seconds); | |
387 } | |
383 } else if (name == "port") { | 388 } else if (name == "port") { |
384 int port; | 389 int port; |
385 if (ParseInt32(value, ParseIntFormat::NON_NEGATIVE, &port)) | 390 if (ParseInt32(value, ParseIntFormat::NON_NEGATIVE, &port)) |
386 ports.insert(port); | 391 ports.insert(port); |
387 } | 392 } |
388 } | 393 } |
389 | 394 |
390 if (line_end >= header_end) | 395 if (line_end >= header_end) |
391 break; | 396 break; |
392 line_start = line_end + 1; | 397 line_start = line_end + 1; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 entry_dict->SetInteger("tries", it->second.count); | 479 entry_dict->SetInteger("tries", it->second.count); |
475 entry_dict->SetInteger("reason", it->second.reason); | 480 entry_dict->SetInteger("reason", it->second.reason); |
476 entry_list->Append(std::move(entry_dict)); | 481 entry_list->Append(std::move(entry_dict)); |
477 } | 482 } |
478 value->Set("blacklisted", std::move(entry_list)); | 483 value->Set("blacklisted", std::move(entry_list)); |
479 | 484 |
480 return std::move(value); | 485 return std::move(value); |
481 } | 486 } |
482 | 487 |
483 } // namespace net | 488 } // namespace net |
OLD | NEW |