Skip to content

Commit 3fad4d5

Browse files
Merge pull request #8384 from Sesquipedalian/2.1/timestamp_clamp
[2.1] Clamps timestamps to accepted range in timeformat() and smf_strftime()
2 parents d4662fb + ee92df0 commit 3fad4d5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/Subs.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,8 @@ function timeformat($log_time, $show_today = true, $tzid = null)
716716
global $context, $user_info, $txt, $modSettings;
717717
static $today;
718718

719+
$log_time = min(max($log_time, PHP_INT_MIN), PHP_INT_MAX);
720+
719721
// Ensure required values are set
720722
$user_info['time_format'] = !empty($user_info['time_format']) ? $user_info['time_format'] : (!empty($modSettings['time_format']) ? $modSettings['time_format'] : '%F %H:%M');
721723

@@ -913,6 +915,8 @@ function smf_strftime(string $format, int $timestamp = null, string $tzid = null
913915
if (!isset($tzid))
914916
$tzid = date_default_timezone_get();
915917

918+
$timestamp = min(max($timestamp, PHP_INT_MIN), PHP_INT_MAX);
919+
916920
// A few substitutions to make life easier.
917921
$format = strtr($format, array(
918922
'%h' => '%b',

0 commit comments

Comments
 (0)