No escaping of special characters when reading files (maps, save games) leads to crash
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
widelands |
Fix Released
|
Low
|
Unassigned |
Bug Description
I was investigating bug 1526916, when I got the idea to test how files with special characters were treated.
There's two ways to trigger this (can possibly argue it should be seperate bugs, but I reckon the fix would be in a central place. Let me know, and I'll split them out).
A:
1. Start a new game.
2. Click save
3. Enter the following name:
<test>
4. Quit the game to main menu.
5. Attempt to enter the load game menu.
B:
1. Go to the editor.
2. Open the menu and click save map.
3. When entering a map (or directory name), use
<test>
4. Attempt to open the save map or go back to the main menu and attempt to start a new game.
In both cases Widelands will crash with an error message saying non-existing file or directory. Interestingly enough, the file "~/.widelands/
(For anyone testing this, you NEED TO MANUALLY go in and remove the file/directory you just created to get Widelands WORKING AGAIN.)
I have to admit I don't know what the proper fix is, especially regarding cross-platform. I believe some filesystems (like NTFS) are much stricter on which characters can be part of file names, so what might be created and work fine on one system could fail on another. (I have no idea how this affects multiplayer where the host distributes a save game or map to other players, but I reckon this might cause problems as well.) An easy fix would be to "add escaping where needed when loading files", but I don't know whether there's a straight-forward way to do this. Preferably we should utilize some existing library we already depend on here, as it is more likely they have already ironed out all the edge cases.
Widelands r7679 on Ubuntu 15.10.
(Regarding importance: I normally rank crashers at least at medium, but this is an odd edge case, and I can't remember seeing this in the wild before)
Related branches
- SirVer: Approve
-
Diff: 861 lines (+181/-185)22 files modifiedsrc/editor/ui_menus/editor_main_menu_map_options.cc (+2/-2)
src/editor/ui_menus/editor_main_menu_random_map.cc (+2/-2)
src/editor/ui_menus/editor_main_menu_save_map.cc (+1/-3)
src/editor/ui_menus/editor_main_menu_save_map_make_directory.cc (+1/-1)
src/editor/ui_menus/editor_player_menu.cc (+1/-1)
src/graphic/CMakeLists.txt (+1/-0)
src/graphic/text_layout.cc (+20/-0)
src/graphic/text_layout.h (+17/-0)
src/graphic/texture_atlas.cc (+1/-0)
src/graphic/wordwrap.cc (+0/-26)
src/ui_basic/editbox.cc (+86/-87)
src/ui_basic/editbox.h (+3/-5)
src/ui_basic/multilinetextarea.cc (+11/-7)
src/ui_basic/multilinetextarea.h (+4/-4)
src/ui_basic/spinbox.cc (+6/-5)
src/ui_fsmenu/internet_lobby.cc (+2/-3)
src/ui_fsmenu/netsetup_lan.cc (+4/-6)
src/wui/building_statistics_menu.cc (+2/-6)
src/wui/game_main_menu_save_game.cc (+12/-16)
src/wui/game_main_menu_save_game.h (+2/-1)
src/wui/gamechatpanel.cc (+1/-2)
src/wui/login_box.cc (+2/-8)
- SirVer: Approve
-
Diff: 25 lines (+21/-0)1 file modifiedtest/maps/plain.wmf/scripting/test_text_renderer_does_not_crash.lua (+21/-0)
Changed in widelands: | |
status: | In Progress → Fix Committed |
assignee: | GunChleoc (gunchleoc) → nobody |
Changed in widelands: | |
status: | Fix Committed → Fix Released |
See also https:/ /en.wikipedia. org/wiki/ Filename# Reserved_ characters_ and_words
Especially for ntfs: https:/ /msdn.microsoft .com/en- us/library/ windows/ desktop/ aa365247% 28v=vs. 85%29.aspx# naming_ conventions