Git Product home page Git Product logo

Comments (6)

fabiangreffrath avatar fabiangreffrath commented on June 5, 2024

Question is, should we (1) just break loops if newargc reaches MAXARGVS and break silently, or (2) abort with an error message or (3) reallocate the newargv[] array and accept an arbitrary number of arguments?

from chocolate-doom.

Henrique194 avatar Henrique194 commented on June 5, 2024

I opt for (2). We have functions like M_FindResponseFile and SetupMission, which will silently ignore extra arguments (so chocolate-doom.exe -response resp1 resp2 ... will be treated as chocolate-doom.exe -response resp1, and chocolate-setup.exe -game doom heretic ... as chocolate-setup.exe -game doom), but they are simply applying the parsing rules, so the user should be aware of how the program will treat each parameter when using them. I would discard option (3), because then we would have to throw away MAXARGVS macro all together, which would break the accuracy with the original code. Considering we want to keep MAXARGVS and that most users don't know about the arguments limit, then (2) seems the appropriate solution.

from chocolate-doom.

turol avatar turol commented on June 5, 2024

Well (1) is definitely wrong. I don't think vanilla supported response files so compatibility is not an issue. (2) sounds easiest to implement. I don't see a need for (3) and it sounds complicated.

I vote for (2).

from chocolate-doom.

Henrique194 avatar Henrique194 commented on June 5, 2024

@turol Original Doom supported response files through @respfile syntax. Chocolate Doom added the option to load response files using -response respfile, because the original syntax was causing some problems in Linux. You can still use the original syntax with Chocolate Doom tough, if you like it. Also, option (3) is not that difficult to implement, we just have to drop the MAXARGVS and call realloc when appropriate while reading the file. We could create a new function, maybe void M_ParseResponseFile(char **newargv, char *respfile), and reuse most of the while loop to implement the reallocation. The reason that option (3) is bad, at least in my opinion, is that we would be driving away too much from the original code if we drop the MAXARGVS.

from chocolate-doom.

turol avatar turol commented on June 5, 2024

What does vanilla do if it's passed too many arguments via response file? Ignore them? Crash? Misbehave in some other way?

from chocolate-doom.

Henrique194 avatar Henrique194 commented on June 5, 2024

@turol Superficially, it looks like the original Doom code seems to allow a buffer overflow. But it may be the case that a buffer overflow would never happen due to some hardware/OS limitation of the time. Also, a second buffer overflow could happen in the original code when filling the array char *moreargs[20]; at this line of code, if myargc - i >= 19. This one can't happen in Chocolate Doom, because we do not use moreargs anymore. I think the only way to be sure is to confirm with Carmack if these problem were mapped at the time, or run a old machine with DOS + DOOM with a big enough response file.

from chocolate-doom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.