Advertisement:

Author Topic: Bug in 2.016 can cause rss feeds to hang  (Read 1651 times)

Offline dcmouser

  • Charter Member
  • Jr. Member
  • *
  • Posts: 208
    • donationcoder.com
Bug in 2.016 can cause rss feeds to hang
« on: December 29, 2019, 10:18:27 AM »
Looks to me like the new 2.016 release has a bug in News.php serving rss feeds.  Took me a while to figure out why our server load was slowly growing out of control -- turns out some rss feeds were hanging in a php infinite loop.
In the function cdata_parse, 2.016 made a change to v2.015, replacing:
Code: [Select]
elseif ($smcFunc['substr']($data, $pos, 1) == ']')
{
$cdata .= ']]>&#093;<![CDATA[';
$pos++;
}

with

Code: [Select]
elseif ($smcFunc['substr']($data, $pos, 3) == ']]>')
{
$cdata .= ']]]]><![CDATA[>';
$pos = $pos + 3;
}

The problem is that the way the function is written, this can cause an infinite loop if it is parsing a post with a ] character in it, because there is no auto-incrementing of the $pos variable and it essentially keeps finding the same ']' and not advancing over it.  The $pos variable essentially loops forever without incrementing, causing an infinite loop.

One way to fix it is to add back in the old code from 2.015, another is to add a catch-all at the end of the elseif blocks like so:
Code: [Select]
else {
// ATTN: 12/29/19 alternate fix for bug introduced in 2.0.16, where $pos stays stuck on a [
// force advance $pos past this character
$pos++;
}

(Another way would be start the loop with $pos = -1 and check to make sure $pos>$old where it makes similar checks).

proud member of donationcoder.com (forum)

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 52,605
Re: Bug in 2.016 can cause rss feeds to hang
« Reply #1 on: December 29, 2019, 10:34:47 AM »
we are well aware of this issue. we are working on getting a patch out to fix this.

Offline m4z

  • 98.8% chimp
  • Localizer
  • Sophist Member
  • *
  • Posts: 1,183
  • /mɛs/
Re: Bug in 2.016 can cause rss feeds to hang
« Reply #2 on: December 29, 2019, 10:37:21 AM »
Thanks for the detailed explanatation and fix! <3 You're awesome!
"Faith is what you have in things that don't exist."
--Homer Simpson

<werbung>Meine Freundin hat ihr erstes Buch veröffentlicht!</werbung>

Online SleePy

  • Let there be light!
  • Site Team Lead
  • SMF Master
  • *
  • Posts: 30,645
  • Gender: Male
  • Thats his happy face.
    • jdarwood007 on GitHub
    • @jdarwood on Twitter
    • SleePy Code - My personal site
Re: Bug in 2.016 can cause rss feeds to hang
« Reply #3 on: December 29, 2019, 11:09:48 AM »
In News.php

Find:
Code: [Select]
$positions = array(
$smcFunc['strpos']($data, '&', $pos),
$smcFunc['strpos']($data, ']', $pos),
);

Replace with:
Code: [Select]
$positions = array(
$smcFunc['strpos']($data, '&', $pos),
$smcFunc['strpos']($data, ']]>', $pos),
);

This will be fixed in the next release (2.0.17).  You will have to revert this change to get 2.0.17 to apply cleanly.
Jeremy D — Site Team / SMF Developer
Support the SMF Support team!
Profiles:
GitHub

Offline spiros

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 1,891
  • Gender: Male
  • A different point of view
    • spiros.doikas on Facebook
    • doikas on LinkedIn
    • @greektranslator on Twitter
    • Greek Translation
Re: Bug in 2.016 can cause rss feeds to hang
« Reply #4 on: December 30, 2019, 04:11:30 AM »
So if someone has not applied 2.0.16 yet, both 2.0.16 and 2.0.17 should be applied when updating?

Offline m4z

  • 98.8% chimp
  • Localizer
  • Sophist Member
  • *
  • Posts: 1,183
  • /mɛs/
Re: Bug in 2.016 can cause rss feeds to hang
« Reply #5 on: December 30, 2019, 04:20:37 AM »
As stated in the release announcement, that depends. If you use the incremental patches, then yes. (But 2.0.17 isn't released yet.)
"Faith is what you have in things that don't exist."
--Homer Simpson

<werbung>Meine Freundin hat ihr erstes Buch veröffentlicht!</werbung>

Offline spiros

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 1,891
  • Gender: Male
  • A different point of view
    • spiros.doikas on Facebook
    • doikas on LinkedIn
    • @greektranslator on Twitter
    • Greek Translation
Re: Bug in 2.016 can cause rss feeds to hang
« Reply #6 on: December 30, 2019, 04:28:10 AM »
Thanks :)

Online shawnb61

  • Developer
  • SMF Hero
  • *
  • Posts: 2,425
    • sbulen on GitHub
Re: Bug in 2.016 can cause rss feeds to hang
« Reply #7 on: December 30, 2019, 02:49:26 PM »
Confirmed & logged as #100. 
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Online shawnb61

  • Developer
  • SMF Hero
  • *
  • Posts: 2,425
    • sbulen on GitHub
Re: Bug in 2.016 can cause rss feeds to hang
« Reply #8 on: December 30, 2019, 10:32:38 PM »
Fixed in 2.0.17
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp