-
Notifications
You must be signed in to change notification settings - Fork 130
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
Fix string out of bounds for asset file opening. #4673
Fix string out of bounds for asset file opening. #4673
Conversation
When opening the assets folder as a file, an out-of-bounds string pointer is passed to AAssetManager_open. b/388599092
AAsset* OpenAndroidAsset(const char* path) { | ||
if (!IsAndroidAssetPath(path) || g_asset_manager == NULL) { | ||
SB_LOG(WARNING) << "Unable to open from Android Asset Manager: " << path; | ||
if (!IsAndroidAssetFile(path) || g_asset_manager == NULL) { | ||
errno = ENOENT; | ||
return NULL; | ||
} | ||
const char* asset_path = path + strlen(g_app_assets_dir) + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we check asset_path has content here?
IsAndroidAssetFile() above only check path has the asset directory + '/', maybe we should check it has content after '/' there, and it does not end with '/'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the memory pointed by the path
pointer corrupted? What is causing that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this PR, the "+1" on line 124 points out of bounds when the asset directory is passed into OpenAndroidAsset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re colin: I don't want to change the logic in this PR, only fix the out-of-bounds pointer resulting in a crash. If the asset directory + '/' is passed, the function behaves the same before and after this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AAssetManager_open can handle empty asset_path? Sounds good to me then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is that even if it can't handle it, that is a separate bug that exists before and after this PR, and it out of scope for this PR.
Gentle ping? |
When opening the assets folder as a file, an out-of-bounds string pointer is passed to AAssetManager_open.
Also remove some logspam.
b/388599092