dMZX Forums: [CHDIR] Loading saves through testing can cause MegaZeux to return to the wrong world -> Archived MegaZeux Bugs -> Tracker

Jump to content

Report ID 337 Title [CHDIR] Loading saves through testing can cause MegaZeux to return to the wrong world
Product Archived MegaZeux Bugs Status Fixed (Severity 5 - Critical)
Version GIT Fixed in GIT
Introduced In Version ----Operating System Windows XP

Page 1 of 1
  • Cannot start a new Issue
  • Closed Issue This issue is locked

Report ID #337: [CHDIR] Loading saves through testing can cause MegaZeux to return to the wrong world

#1 User is offline  
Old-Sckool 

  • megazeux breaker
  • PipPipPipPip
  • Group: Members
  • Posts: 649
  • Joined: 07-June 05
  • Gender:Male

Posted 01 February 2011 - 09:28 AM

Pretty crazy bug this time...
If you create a new world, test it from the editor, and load a save from a different directory, MegaZeux will change the directory in which to look for the world file, leaving behind a __test.mzx file in Directory 1. When the game is left through escape, will MegaZeux fail to find the last world, and just simply creates a whole world from scratch, while retaining the same editor state from the last world. From here you can Alt-T -> Load a save in side Directory 1 -> escape to return to the original project without throwing the world not found error, while leaving behind another __test.mzx file in Directory 2. You can then hop between both directories in the same as long as there is a __test.mzx within each of them. And since the editor returns to the same state, you can easily crash MegaZeux in a number of ways (Like getting the cursor out of bounds by adjusting the board parameters, or simply leaving from one world on a board number that doesn't exist in the other.)
<Nadir> mzxers don't make GAMES, usually
<phthalocyanine> they make experiences.
<Nadir> demos, more like
<Nadir> a glimpse into what could have been if mzx wasn't such a bore to work with
<Nadir> actually, i'm being unfair
<Nadir> i would have made mzx games if it was capable of running on more than 20 computers worldwide in 1998
<Nadir> >:D

<%Alice> functor
<%nooodl> i hear C++ has a thing called functors and they're completely different from Haskell functors...
<rorirover> the result is the most horrid thing in C++, it's basically black magic and it transforms any code you're writing into some eldritch monstrosity


Page 1 of 1  
  • Cannot start a new Issue
  • Closed Issue This issue is locked

Replies (1 - 8)

#2 User is offline  
Terryn 

  • ******
  • Group: DigiStaff
  • Posts: 2,966
  • Joined: 12-October 00
  • Gender:Male

Posted 24 September 2011 - 05:03 PM

Updating status to: Confirmed
Updating severity to: 5 - Critical

Confirming. While something very few people would come across on accident, it's a definite crash bug and does take out MZX by doing the things described.
angelic stream - shed sanguine - ill-adapt - avis - para/lyser - renaissance - dead tangent - phosphene blur - birth breeds death - ________ - painted glass - lagniappe

<Exophase> HES STEALING MAH AIRSHIP!!!!!!11111111

#3 User is offline  
ajs 

  • carpe diem
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,614
  • Joined: 21-October 00
  • Gender:Male
  • Location:United Kingdom

Posted 18 October 2011 - 09:42 PM

MZX is using chdir() when saving, but not correctly chdir()'ing back to the original directory. Similar to bug #387.

--ajs.

#4 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,949
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 19 May 2012 - 05:08 AM

Updating version to: GIT


Copied from PM for futer reference.

Quote

14:51:34 <ajs> Plan for removing the chdir involved making all the internal paths absolute, except of course when they're saved out in the world file or similar.
14:52:14 <ajs> So when you load a file it's stored as /path/to/mzx/file.mzx and when you save a game is does the equivalent of 'dirname' to get get the base path for the dialog listing
14:52:41 <ajs> This should stop all the bugs where the user does something unexpected during testing that causes the directory to be switched and forgetting to switch back in the editor
14:53:05 <ajs> As the files open for edit and whatever the game's state is are totally orthogonal
14:53:42 <ajs> MZX was engineered assuming that the CWD was where it was installed, but that's never been true on non-Windows platforms
14:53:58 <ajs> You shouldn't trust the CWD except to use it as your starting path.

"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#5 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,949
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 23 May 2012 - 01:53 AM

Updating status to: Flagged For Future Version

Flagged for 2.84b. This is going to be a nightmare and I'd rather not screw up an otherwise good-looking (and very late) release because of it.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#6 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,949
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 02 June 2012 - 04:34 AM

Occurrences of chdir (including some related stuff that came up in the grep)

editor/edit.c:1051:  chdir(config_dir);
editor/edit.c:1053:  chdir(current_listening_dir);
editor/edit.c:2376:              chdir(current_listening_dir);
editor/edit.c:2388:              chdir(current_dir);
editor/edit.c:3298:              chdir(current_listening_dir);
editor/edit.c:3300:              chdir(current_dir);
game.c:2161:  chdir(config_dir);                                       title_screen() for title.cnf
game.c:2163:  chdir(current_dir);                                      ""
game.c:2272:            chdir(config_dir);                             "" restore for game.cnf
game.c:2274:            chdir(current_dir);                            ""
game.c:2371:            chdir(config_dir);                             "" play for game.cnf
game.c:2373:            chdir(current_dir);                            ""
game.c:2490:          chdir(config_dir);                               "" quickload for game.cnf
game.c:2492:          chdir(current_dir);                              ""
main.c:95:  chdir(config_dir);
main.c:112:  chdir(current_dir);
platform_sdl.c:40:#include <unistd.h> //for chdir, execl
platform_sdl.c:84:  chdir("/usr/gp2x");
updater.c:231:  if(chdir(base_path))
updater.c:248:  if(chdir(previous_dir))
updater.c:411:    goto err_chdir;
updater.c:747:err_chdir:
util.c:133:    chdir(bin_path);
util.c:160:      chdir(CONFDIR);
util.c:162:      chdir(SHAREDIR);
util.c:192:      chdir(bin_path);
utils/checkres.c:215:      if(chdir(path))
utils/checkres.c:484:      return "Failed to chdir() into parent path.";
window.c:2159:  chdir(directory_name);
window.c:2183:  chdir(current_dir_name);
window.c:2237:    if(!chdir(current_dir_name))
window.c:2379:        if(devoptab_list[i] && devoptab_list[i]->chdir_r)
window.c:2449:          chdir("..");
window.c:2475:          chdir(ret);
window.c:2485:            chdir(path);
window.c:2508:            chdir(path);
window.c:2523:        chdir(dir_list[chosen_dir]);
window.c:2648:    chdir(previous_dir_name);
window.c:2668:      chdir(previous_dir_name);
world.c:1138:      chdir(file_path);


fopen_unsafe
audio.c:898:  FILE *input_file = fopen_unsafe(filename, "rb");
audio.c:1091:  fp = fopen_unsafe(file, "rb");
audio.c:1264:  source = fopen_unsafe(source_name, "rb");
audio.c:1268:  dest = fopen_unsafe(dest_name, "wb");
audio.c:1339:      FILE *f = fopen_unsafe(translated_filename_dest, "r");
audio.c:1374:      FILE *f = fopen_unsafe(translated_filename_dest, "r");
audio_mikmod.c:191:  input_file = fopen_unsafe(filename, "rb");
audio_modplug.cpp:185:  input_file = fopen_unsafe(new_file, "rb");
commands:223:counter.c:          mzx_world->input_file = fopen_unsafe(translated_path, "rb");
commands:624:helpsys.c:  mzx_world->help_file = fopen_unsafe(file_name, "rb");
commands:1132:world.c:        mzx_world->input_file = fopen_unsafe(translated_path, "rb");
compat.h:143:// fsafetranslate()+fopen_unsafe(), or call fsafeopen() directly.
compat.h:146:// probably should not be translated. In this case fopen_unsafe() can be
compat.h:151:static inline FILE *fopen_unsafe(const char *path, const char *mode)
compat.h:156: { return fopen_unsafe(path, mode); }
compat.h:162:#define fopen_unsafe(file, mode) fopen(file, mode)
configure.c:551:  conf_file = fopen_unsafe(conf_file_name, "rb");
counter.c:2564:          mzx_world->input_file = fopen_unsafe(translated_path, "rb");
editor/edit.c:2131:                  sfx_file = fopen_unsafe(import_name, "rb");
editor/edit.c:2309:                  sfx_file = fopen_unsafe(export_name, "wb");
editor/debug.c:255:        fp = fopen_unsafe(export_name, "wb");
editor/graphics.c:55:  FILE *pal_file = fopen_unsafe(fname, "wb");
editor/graphics.c:98:  FILE *fp = fopen_unsafe(name, "wb");
editor/robo_ed.c:1754:      export_file = fopen_unsafe(export_name, "wb");
editor/robo_ed.c:1771:      export_file = fopen_unsafe(export_name, "w");
editor/robo_ed.c:1800:  import_file = fopen_unsafe(import_name, "r");
editor/board.c:62:  FILE *input_mzb = fopen_unsafe(name, "rb");
editor/board.c:177:  FILE *board_file = fopen_unsafe(name, "wb");
fsafeopen.c:400:  f = fopen_unsafe(newpath, mode);
graphics.c:136:  FILE *fp = fopen_unsafe(name, "rb");
graphics.c:155:  FILE *fp = fopen_unsafe(name, "rb");
graphics.c:171:  FILE *fp = fopen_unsafe(name, "rb");
graphics.c:429:  pal_file = fopen_unsafe(fname, "rb");
graphics.c:1572:  file = fopen_unsafe(name, "wb");
helpsys.c:37:  mzx_world->help_file = fopen_unsafe(file_name, "rb");
mzm.c:33:  FILE *output_file = fopen_unsafe(name, "wb");
mzm.c:234:  FILE *input_file = fopen_unsafe(name, "rb");
network/manifest.c:190:  f = fopen_unsafe(MANIFEST_TXT, "rb");
network/manifest.c:213:  f = fopen_unsafe(MANIFEST_TXT, "w+b");
network/manifest.c:336:    f = fopen_unsafe(e->name, "rb");
network/manifest.c:418:  f = fopen_unsafe(e->name, "w+b");
network/manifest.c:431:    f = fopen_unsafe(e->name, "w+b");
pngops.c:35:  f = fopen_unsafe(name, "wb");
pngops.c:111:  f = fopen_unsafe(name, "rb");
render_glsl.c:189:  f = fopen_unsafe(filename, "rb");
updater.c:193:  f = fopen_unsafe(file, "rb");
updater.c:275:  input = fopen_unsafe(MANIFEST_TXT, "rb");
updater.c:279:  output = fopen_unsafe(MANIFEST_TXT "~", "wb");
updater.c:407:  f = fopen_unsafe(UPDATES_TXT, "w+b");
updater.c:716:    f = fopen_unsafe(DELETE_TXT, "wb");
updater.c:789:  f = fopen_unsafe(DELETE_TXT, "rb");
updater.c:798:    f = fopen_unsafe(e->name, "rb");
utils/checkres.c:172:  fp = fopen_unsafe(filename, "rb");
utils/checkres.c:225:    (*s)->stream.fp = fopen_unsafe(filename, mode);
utils/downver_283_to_282.c:375:  fp = fopen_unsafe(argv[1], "r+b");
utils/downver.c:156:  fp = fopen_unsafe(argv[1], "r+b");
utils/downver_template.c:305:  fp = fopen_unsafe(argv[1], "r+b");
utils/png2smzx.c:104:   fd = fopen_unsafe(argv[2], "wb");
utils/png2smzx.c:124:   fd = fopen_unsafe(argv[3], "wb");
utils/png2smzx.c:135:   fd = fopen_unsafe(argv[4], "wb");
window.c:2296:                  FILE *mzx_file = fopen_unsafe(file_name, "rb");
world.c:189:  source = fopen_unsafe(file_name, "rb");
world.c:206:  dest = fopen_unsafe(file_name, "wb");
world.c:374:    fp = fopen_unsafe(file, "rb");
world.c:395:  fp = fopen_unsafe(file, "wb");
world.c:969:  fp = fopen_unsafe(file, "rb");
world.c:1363:        mzx_world->input_file = fopen_unsafe(translated_path, "rb");

"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#7 User is offline  
Terryn 

  • ******
  • Group: DigiStaff
  • Posts: 2,966
  • Joined: 12-October 00
  • Gender:Male

Posted 03 June 2012 - 09:43 PM

Updating status to: Confirmed

Hup
angelic stream - shed sanguine - ill-adapt - avis - para/lyser - renaissance - dead tangent - phosphene blur - birth breeds death - ________ - painted glass - lagniappe

<Exophase> HES STEALING MAH AIRSHIP!!!!!!11111111

#8 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,949
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 05 June 2012 - 07:00 AM

Updating status to: Fixed
Issue fixed in: GIT

Yeah, I think eliminating chdir from MZX is pretty much impossible/stupidly difficult at this point and with my experience in the MZX source, so I fixed this with another chdir. Wowowowowowowowowowowow!!!!!1 GIT master/08d7e57
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#9 User is offline  
Terryn 

  • ******
  • Group: DigiStaff
  • Posts: 2,966
  • Joined: 12-October 00
  • Gender:Male

Posted 18 June 2012 - 05:58 AM

Moving to: Archived MegaZeux Bugs


Page 1 of 1
  • Cannot start a new Issue
  • Closed Issue This issue is locked

0 User(s) are reading this issue
0 Guests and 0 Anonymous Users


Powered by IP.Tracker 1.3.2 © 2025  IPS, Inc.