Skip to content

Commit

Permalink
Merge pull request #8384 from Sesquipedalian/2.1/timestamp_clamp
Browse files Browse the repository at this point in the history
[2.1] Clamps timestamps to accepted range in timeformat() and smf_strftime()
  • Loading branch information
Sesquipedalian authored Dec 31, 2024
2 parents d4662fb + ee92df0 commit 3fad4d5
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 3fad4d5

Please sign in to comment.