slajerek / RetroDebugger

Retro Debugger is a multiplatform debugger APIs host for retro computers: C64 (Vice), Atari800 and NES (NestopiaUE).
187 stars 23 forks source link

Command line arguments not working on Linux? #69

Open 3vi1 opened 3 weeks ago

3vi1 commented 3 weeks ago

I've tried to start RetroDebugger with various command line options to load a PRG file (ex.: "retrodebugger -c64 build/test.prg", "retrodebugger -c64 -prg build/test.prg", "retrodebugger -prg build/test.prg", etc.). RD starts without error, but it never loads the PRG.

I can load the same PRG fine if I load it from the menus after startup.

BTW: Testing just "retrodebugger build/test.prg" on Linux results in " buffer overflow detected : terminated". This is using the latest retrodebugger compiled from source on Linux - which seems to work fine in every other way.

Is there just some simple formatting thing that I'm missing?

3vi1 commented 2 weeks ago

I did a little debugging into the buffer overflow that occurs when trying to start RetroDebugger with a single .prg path parameter:

On my system, it aborts when parsing the avahi process. proc_find_other_instance gets to line 222 and ends up thinking the fileName should be "avahi-daemon:" since it's not a real path in the command. This leads to MTEngineSDL's SYS_Funct/SYS_GetFileNameWithExtensionFromFullPath trying to do a strcpy (line 346) of the filename to a return buffer.

It looks like there wouldn't be room for the null terminating character since the array was created to be the exact length of the string - causing the buffer overflow.

3vi1 commented 2 weeks ago

Confirmed. I added a +1 to the length declaration and I can now load from the command line. I'll fork and submit a pull request, if that works for you.

https://github.com/slajerek/MTEngineSDL/pull/8