mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-26 16:26:44 +03:00
Merge pull request #1914 from sgoranov/fix/1913-datetime-overflow
Fix DateTimeHelper::ParseRFC2822DateString integer overflow on 32-bit PHP
This commit is contained in:
commit
24bb509b96
1 changed files with 14 additions and 3 deletions
|
|
@ -54,11 +54,22 @@ abstract class DateTimeHelper
|
||||||
\DateTime::createFromFormat('d M Y H:i:s O', $sDateTime, static::GetUtcTimeZoneObject())
|
\DateTime::createFromFormat('d M Y H:i:s O', $sDateTime, static::GetUtcTimeZoneObject())
|
||||||
// Using T (obsolete timezone abbreviation)
|
// Using T (obsolete timezone abbreviation)
|
||||||
?: \DateTime::createFromFormat('d M Y H:i:s T', $sDateTime, static::GetUtcTimeZoneObject());
|
?: \DateTime::createFromFormat('d M Y H:i:s T', $sDateTime, static::GetUtcTimeZoneObject());
|
||||||
// 398045302 is 1982-08-13 00:08:22 the date RFC 822 was created
|
|
||||||
if (!$oDateTime || 398045302 > $oDateTime->getTimestamp()) {
|
try {
|
||||||
|
$timestamp = $oDateTime->getTimestamp();
|
||||||
|
|
||||||
|
// 398045302 is 1982-08-13 00:08:22, the date RFC 822 was created
|
||||||
|
if (398045302 > $timestamp) {
|
||||||
|
\SnappyMail\Log::notice('', "Failed to parse RFC 2822 date '{$sDateTime}'");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $timestamp;
|
||||||
|
} catch (\Error $error) {
|
||||||
|
// Catch integer overflow or other fatal errors
|
||||||
\SnappyMail\Log::notice('', "Failed to parse RFC 2822 date '{$sDateTime}'");
|
\SnappyMail\Log::notice('', "Failed to parse RFC 2822 date '{$sDateTime}'");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return $oDateTime ? $oDateTime->getTimestamp() : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue