Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changelog button crashes the game if NewGRF contains relative folder #8886

Closed
telk5093 opened this issue Mar 23, 2021 · 4 comments
Closed

Changelog button crashes the game if NewGRF contains relative folder #8886

telk5093 opened this issue Mar 23, 2021 · 4 comments

Comments

@telk5093
Copy link
Contributor

Version of OpenTTD

20210322-master-gf9d24ff45e

Expected result

Changelog button is disabled

Actual result

Changelog button is enabled and crashes if I click it:
image

Steps to reproduce

I recently updated my NewGRF and it contains a markdown file, which is named changelog.md
It is awkward that Changelog button appears when changelog.md file exists, even though I refered a related codes at

const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filename)

  1. Download Korean Train Set 2.0.0-beta1
  2. Put it /newgrf or /content_download/newgrf folder
  3. Open NewGRF Settings window, select Korean Train Set 2.0.0-beta1, and click changelog
@LordAro
Copy link
Member

LordAro commented Mar 23, 2021

So this is good...

Due to the command used to create your tar file, it appears to contain a folder named '.'. Normally, this just means "current directory". OTTD then looks on this path and finds... its own changelog.txt, which it then crashes trying to display it (known issue, it's too big)

@LordAro LordAro changed the title Changelog button crashes the game if NewGRF contains changelog.md Changelog button crashes the game if NewGRF contains relative folder Mar 23, 2021
@telk5093
Copy link
Contributor Author

Then, it won't crash anyway if I remove dots for my grf for now! Thanks for it.

@James103
Copy link
Contributor

Actually, when the game tries to display any file in its readme viewer that is longer than 6,553 lines, it crashes with the same assertion as in the original comment:

assert(num <= MAX_UVALUE(uint16));

This means that not only is OpenTTD's changelog.txt able to cause the crash when "Wrap Text" is enabled (and unconditionally starting from 1.12 or 1.13 onward), but also a NewGRF, AI, or GS can crash the game simply by a user clicking on the readme, changelog, or license buttons when their corresponding files have 6,554 lines or more (whether raw or after "Wrap Text").

Fun fact: 6,553 * 10 < 65,536 < 6,554 * 10, which means the assertion is triggered based on the total number of vertical pixels, of which there are 10 per line.

@nielsmh
Copy link
Contributor

nielsmh commented Mar 24, 2021

Need to finish #7786 or maybe at least pull some of the text file viewer improvements out of it so they can be committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants