Windows: Fix CefCookieVisitor crash on invalid date (fixes issue #2927)

This commit is contained in:
Marshall Greenblatt 2020-06-30 14:32:48 -04:00
parent 0dfefe391c
commit 5c1118230d
2 changed files with 13 additions and 1 deletions

View File

@ -20,6 +20,16 @@ void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time) {
}
void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time) {
#if defined(OS_WIN)
int64_t t = time.ToDeltaSinceWindowsEpoch().InMicroseconds();
// From MSDN, FILETIME "Contains a 64-bit value representing the number of
// 100-nanosecond intervals since January 1, 1601 (UTC)." This value must
// be less than 0x8000000000000000. Otherwise, the function
// FileTimeToSystemTime fails.
if (t < 0 || static_cast<uint64_t>(t * 10) >= 0x8000000000000000)
return;
#endif
base::Time::Exploded exploded;
time.UTCExplode(&exploded);
cef_time.year = exploded.year;

View File

@ -569,7 +569,9 @@ class CookieTestJSHandler : public TestHandler {
std::string page =
"<html><head>"
"<script>"
"document.cookie='name1=value1';"
"document.cookie='name1=value1;"
// Invalid date should not cause a crash (see issue #2927).
" expires=Tue, 07 Nov 94276 07:58:05 GMT'"
"</script>"
"</head><body>COOKIE TEST1</body></html>";
AddResource(kCookieJSUrl1, page, "text/html");