segfault when trying to preload invalid file
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
widelands |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
I was trying to find ways to accidentally trigger errors Widelands, and I stumbled upon a crash:
1. Copy some non-empty file (which isn't a Settler-2-map) into your maps directory and change its extension to ".swd".
2. Open the Widelands editor, then open the Load or Save dialogue (and open the directory with that file if not already in there).
Result (in most cases): The application crashes (segmentation fault). No error message, no log output.
Weirdly when I started adding some output in src/editor/
I assume the preloader tried - based on some invalid data it read - to access memory it wasn't allowed to. (And when I had added some output, the addressed memory coincidentally was "safe" because part of memory used by the game.)
Not sure how serious we want to take this. I wouldn't really expect any invalid S2 maps to accidentally land in any Widelands map folder. Maybe this can also happen for Widelands maps though, then this scenario might occur more easily.
I'm not sure how much time I have next week, but I'll try to go over the preloaders and add some validity checks where necessary.
Related branches
- GunChleoc: Approve
-
Diff: 58 lines (+31/-1)1 file modifiedsrc/map_io/s2map.cc (+31/-1)
Changed in widelands: | |
milestone: | none → build21-rc1 |
status: | New → Confirmed |
It is always possible that files can become corrupt, so a check is a good idea :)