Simple Machines Community Forum

SMF Development => Bug Reports => Topic started by: Dav999 on February 11, 2023, 12:20:48 PM

Title: [quote date=] with huge date causes PHP/500 errors (SMF 2.0 and 2.1)
Post by: Dav999 on February 11, 2023, 12:20:48 PM
I saw some error messages coming from old posts on my SMF 2.0 forum:

getdate(): Argument #1 ($timestamp) must be of type ?int, float given
It turns out that in 2016, playful members would sometimes replace the quote timestamps by gigantic numbers, like the following:
[quote author=Author link=topic=1234.msg1234#msg1234 date=43221236679945679975421332243343546864502]

This probably had the effect of actually showing correct heat-death-of-the-universe dates with the SMF and PHP versions of the time. However, this has since been causing more errors: I remember seeing similar errors in my log years after the posts were made, but the entire topic would still load and the dates would be blank ("Quote from: author on "). With SMF 2.0.19 on PHP 8.0.25 however, the topic crashes entirely:

(https://i.imgur.com/8VbpsfG.png)

On 2.1.3, such a topic results in a complete 500 Internal Server Error.

It's also not possible to post or preview a message with these contents, as it will result in the same An Error Has Occurred message on 2.0, and a complete 500 error in 2.1.

This is the full error logged in SMF 2.1:

[11-Feb-2023 17:05:10 Europe/Berlin] PHP Fatal error:  Uncaught TypeError: smf_strftime(): Argument #2 ($timestamp) must be of type ?int, string given, called in /home/tolp/public_tolp_testforum/smf_2.1/Sources/Subs.php on line 756 and defined in /home/tolp/public_tolp_testforum/smf_2.1/Sources/Subs.php:903
Stack trace:
#0 /home/tolp/public_tolp_testforum/smf_2.1/Sources/Subs.php(756): smf_strftime('%b %d, %Y, %I:%...', '432212366799456...', 'Europe/Berlin')
#1 /home/tolp/public_tolp_testforum/smf_2.1/Sources/Subs.php(3441): timeformat('432212366799456...')
#2 /home/tolp/public_tolp_testforum/smf_2.1/Sources/Post.php(2063): parse_bbc('[quote author=A...', false)
#3 /home/tolp/public_tolp_testforum/smf_2.1/index.php(191): Post2()
#4 {main}
  thrown in /home/tolp/public_tolp_testforum/smf_2.1/Sources/Subs.php on line 903

I get that it's something that members are not supposed to be doing, but this allows members to spam error logs and waste admins' time, and old playful posts can render part or all of a topic, a member's posts page, etc inaccessible.
Title: Re: [quote date=] with huge date causes PHP/500 errors (SMF 2.0 and 2.1)
Post by: lntit on May 26, 2023, 07:55:48 PM
Sorry for bringing this topic up, but I've discovered a similar error related with that timestamp.
This issue occour too when using the [time] tag.
If the value has more than 18 digits like [time]9999999999999999999[/time] or [time]-9999999999999999999[/time], SMF will throw an error message, similar to that what the OP has posted, while in older posts the page looks cutted from the reply on where that code was once posted.

A possible solution would be a small function that trims all time values that are longer than 18 digits or cut it down to the current system's maximum supported amount of digits.
Title: Re: [quote date=] with huge date causes PHP/500 errors (SMF 2.0 and 2.1)
Post by: m4z on June 14, 2023, 03:03:30 AM
Now tracked as https://github.com/SimpleMachines/SMF/issues/7768