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
Overflow on BSP parsing (read after the lump length) #649
Comments
|
According to the error message this is a gamelogic issue and not necessarily an overflow in the technical sense, either. Not sure if this can be characterized as a bug or whether the game just parses the map file differently than maybe an editor does. |
|
This message: means the next character after the last |
|
Please explain why it's important that the engine handles badly formatted BSPs differently or why they're properly formatted. |
|
In general when reading assets the engine should be robust to bad assets, I think the code to fix this is in CM. @illwieckz can I have the bad map for repro? |
|
@Viech: For example if the last bytes are, @Kangz: yes I can build a bad bsp with explicitely missing It's just another |
|
These two maps are plat23 remixes: They differs from only one bytes (except the fact that the entities are not listed in the same order but don't care about that, it's not a problem), the second one has a null-terminated entities lump: As you see, the next lump after the entities lump is the texture lump (I decided that), the only difference is the With Unvanquished binary from Debian package I get: As you see, each time the engine overflows, it reads something different, so it means it reads a memory that is not the next lump in the bsp but another memory area (in my bsp, the next lump is the texture lump, so the first char is But if I do (Unvanquished binary from Debian package): The map loads without complain. Perhaps this build fills the memory with zeros before? With my own compiled binary I get: So to track the bug, it seems to depend on which |
|
I see your point now, though the gamelogic shouldn't be able to access engine memory due to sandboxing, except if built as a shared library. Thus, if a map is able to manipulate a (non-dll) gamelogic, that shouldn't be much different from a gamelogic built with malicious intent. In that light I don't think the gamelogic does anything particularly careless here, but a fix obviously doesn't hurt. |
|
I was not able to repro but did a blind fix nonetheless, the renderer has similar code but uses strncpyz so it adds the null character. @illwieckz can you check it fixes it for you? |
|
Hi! Hmm, same here: Edit: I used this command: Edit: same with
|
|
Compiling with RelWithDebInfo would give better backtraces ;-) |
|
Was not able to undestand what happens, I am not making full sense of what is happening when static objects are being destructed. |
|
Hum, compiling with RelWithDebInfo just make the bug disappear. o.O |
|
Hmm, I don't know what happens there, now, your code seems to work today, but not yesterday… Now I can't reproduce the bug. So it seems fixed. |
If I (un)intentionally forget to put a NULL character to terminate the Entities lump, the engine fails to load the BSP and prints a message like that:
So it means the engine does not use the lump length to prevent reading outside the Entities lump if this one is not NULL terminated. Since there is no standard lump order, I can chose which lump I put right after the Entities lumps, so I can chose which lump the engine will read while overflowing.
The text was updated successfully, but these errors were encountered: