Skip to content

Commit

Permalink
Clamps timestamps to accepted range in timeformat() and smf_strftime()
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <[email protected]>
  • Loading branch information
Sesquipedalian committed Dec 30, 2024
1 parent d4662fb commit ee92df0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/Subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ function timeformat($log_time, $show_today = true, $tzid = null)
global $context, $user_info, $txt, $modSettings;
static $today;

$log_time = min(max($log_time, PHP_INT_MIN), PHP_INT_MAX);

// Ensure required values are set
$user_info['time_format'] = !empty($user_info['time_format']) ? $user_info['time_format'] : (!empty($modSettings['time_format']) ? $modSettings['time_format'] : '%F %H:%M');

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

$timestamp = min(max($timestamp, PHP_INT_MIN), PHP_INT_MAX);

// A few substitutions to make life easier.
$format = strtr($format, array(
'%h' => '%b',
Expand Down

0 comments on commit ee92df0

Please sign in to comment.