Tiny Tiny RSS: Community

Memory issue in "is_gzipped" function

Ran into a weird issue today with the Jalponik feed and having “Cache media” selected.
Feed: https://jalopnik.com/rss/vip
Article that caused issue: https://gizmodo.com/im-willing-to-pay-an-obscene-amount-of-money-for-this-g-1839720875

Started seeing an error:
PHP: Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted… classes/rssutils:1554

It appears that the article included a 29MB gif and that was being passed to the mb_strpos function.
Does the full $feed_data need to be passed to this function to detect if it’s gzipped?

tt-rss version (including git commit id):
v19.8 (6060963)

Platform (i.e. Linux distro, PHP, PostgreSQL, etc) versions:
Alpine, php 7.3.11, Postgres 11

yes, but we only need to check first three bytes, so using mb_strpos() on the entire buffer was unnecessary. using the multibyte variant of strpos was not necessary either, i think.

e: thanks for reporting this.

Sounds reasonable to use strpos since you’re only checking for bytes and not characters. Thanks for the quick fix!

Q: regarding the PR, why not do a string compare instead of a ‘strpos’ now that you are comparing 3 bytes to 3 bytes?

yeah i thought about replacing it right after committing but figured it wasn’t worth the effort.

if you want to file a PR over this, i’ll merge it.