Fix null-termination and resource leaks in asset loading#19
Merged
MisterGatto merged 1 commit intoskyprotocol:osp-masterfrom Mar 28, 2026
Merged
Fix null-termination and resource leaks in asset loading#19MisterGatto merged 1 commit intoskyprotocol:osp-masterfrom
MisterGatto merged 1 commit intoskyprotocol:osp-masterfrom
Conversation
CipherUtils::readAsset(): allocate +1 for null terminator, close AAsset on malloc and read failure paths. IconLoader::uploadImageKtx(): fix dangling stack reference in die() by using a static sentinel, close AAsset and free buffer on all error paths, add missing return on glGenTextures failure.
Contributor
Author
|
CI failed during release packaging due to a keystore password mismatch. Pre-existing issue, unrelated to this commit. |
Collaborator
|
MuMu specifically needs a different package name which is com.tgc.sky.android.sml to not crash, Ionly know of Bluestacks that works with no issue with normal name, does this only happens with your mod? Because if it does and the fix you proposed is working without giving any issues for Android users then we can squash and merge, I'm currentyl unable to make a debug build because I can't use my PC, if you can send the apk via telegram or another platform I will begin testing in Canvas cord. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Hey I think we hit a crash loop under houdini (ARM-on-x86 emulators) caused by readAsset returning a char* with no null terminator. json::parse calls strlen on it, which walks past the allocation into unmapped memory. On native ARM64, this never surfaces because adjacent heap bytes tend to be zeroed by luck. On houdini the memory layout is different and it faults immediately.
Any mod using read_asset as a C string has the same latent UB.
Proposed fix
Testing
Open to discussion and happy to adjust if needed.