-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when importing broken dae files #46548
Comments
godot/editor/import/editor_import_collada.cpp Lines 712 to 713 in bd42a6c
Is this should have an additional index ? ERR_FAIL_INDEX_V(uv_pos + 1, uv_src->array.size(), ERR_INVALID_DATA); |
I've looked into this and just adding index checks improves the situation. However, the homegrown XML parser is not robust enough to handle malformed XML. For the provided test inputs, the parser cursor advances beyond the input file causing uninitialized / unmapped memory to be read. Looking at the parsing logic, there seems to very little room for error. The parser was probably written with the assumption that the input XML is valid. I see the following options:
|
How much effort in code and time do you think it would be to get a more robust xml parser? |
I'd say that depends on how robust it should be. Parsers in general are notorious for being error prone. Many security issues originate from feeding malformed input to a parser. While I don't think security is a real concern here, writing your own parser for a given file format is something I simply do not recommend. As noted in 3, I'd use an established XML parser/library instead. Libxml2 and Expat seem to be regularly used in the Linux world. Some C++ projects seem to rely on RapidXml. Could one fix/rewrite the parser to be robust enough for our use-cases? Probably. Very rough estimate: ~ 10 hours, probably less. However, I think this is more of a which approach do we take, in general question. As pretty much the same arguments can be made for other parsers, like |
This patch improves the robustness of the XML parser. It should no longer run off beyond the input, accessing uninitilized/unmapped memory. fix godotengine#46548
After thinking about it a bit more, here's a relatively small patch that prevents the parser from simply running off into oblivion. IMHO there is still too little error propagation, but at least it doesn't crash anymore and the API hasn't changed. |
ref godotengine#46548 (cherry picked from commit 8faeb72)
ref godotengine#46548 (cherry picked from commit 8faeb72)
Godot 4 doesn't crash as of V-Sekai@96410f5 when opening the import project. |
I recommend verifying that the XML parser has been fixed in the meantime and does not read beyond end-of-input on broken XML files. Just because Godot does not crash anymore doesn't mean that everything is handled correctly now. |
Can you open an issue for verifying broken XML? Not sure how to define all bugs are removed from xml parsing though. |
Godot version:
3.2.4.rc.custom_build. 8385a0d
OS/device including version:
Ubuntu 20.04
Issue description:
When trying to open broken bmp file, then Godot crashes with this backtrace:
Steps to reproduce:
Minimal reproduction project:
ImportFiles.zip
The text was updated successfully, but these errors were encountered: