Page 1 of 1

Crash with alias in KEYCONF that is > 4090

Posted: Fri Mar 02, 2018 10:23 pm
by m8f
Two files: bad.pk3 and good.pk3.
Both contain a KEYCONF lump with alias "alias1".
In good.pk3, alias1 has length of 4089. good.pk3 is loaded without problems.
In bad.pk3, alias1 has length of 4090. GZDoom crashes on loading bad.pk3:
Spoiler:
No message about problem source is seen, so user who created such an alias has to understand by himself that the problem is in alias length.

You can see that good.pk3:KEYCONF contains more text than bad.pk3, so the problem is not KEYCONF size, but the size of alias.

I see several possible solutions:
  • crash with message about too big alias
  • ignore too big aliases with a warning

Re: Crash with alias in KEYCONF that is > 4090

Posted: Sat Mar 03, 2018 1:40 am
by Graf Zahl
The KEYCONF parser uses a fixed size buffer of 4096 bytes. Congratulations, you are the first person to exceed it!

Re: Crash with alias in KEYCONF that is > 4090

Posted: Sat Mar 03, 2018 2:00 am
by _mental_
It's fairly easy to support arbitrary line lengths in KEYCONF, at cost of heap allocation(s) of course.
Usefulness of this is questionable but crash will be fixed as a side effect.

Re: Crash with alias in KEYCONF that is > 4090

Posted: Sat Mar 03, 2018 2:09 am
by m8f
About usefulness - there would be no need to write long aliases if wait commands were serialized (described here).
If commands with 'wait' could be aliased safely, it would be sufficient just to issue a warning on too long lines (warning would ask to divide line to aliases), and then ignore long lines. And there would be no need to support arbitrary lengths.

Re: Crash with alias in KEYCONF that is > 4090

Posted: Sat Mar 03, 2018 2:11 am
by Graf Zahl
Fixing the buffer overflow is a lot simpler than redesigning the entire system, though.