Repository navigation
Remote Config (Android): pass blob.data() to Variant::FromMutableBlob - #1993
Open
AustinBenoit wants to merge 1 commit into
Open
AustinBenoit wants to merge 1 commit into
AustinBenoit wants to merge 1 commit into
Conversation
In RemoteConfigValueToVariant(), the byte-array conversion branch passed &blob (the address of the local std::vector<unsigned char> object on the stack) instead of blob.data() to Variant::FromMutableBlob(), causing an out-of-bounds stack read for payloads larger than sizeof(blob) and corrupting returned binary Variant values in GetAll().
Contributor
There was a problem hiding this comment.
Code Review
This pull request fixes an out-of-bounds stack read in the Android Remote Config implementation. In remote_config_android.cc, the code was incorrectly passing the address of the std::vector container (&blob) instead of the pointer to its underlying data (blob.data()) to Variant::FromMutableBlob. This has been corrected to use blob.data(). The release notes in readme.md have also been updated to reflect this fix. There are no review comments, and I have no feedback to provide.
| @@ -1292,7 +1292,7 @@ static Variant RemoteConfigValueToVariant(JNIEnv* env, jobject from) { | |||
| if (!CheckKeyRetrievalLogError(env, "", "vector")) { | |||
| std::vector<unsigned char> blob = | |||
There was a problem hiding this comment.
Add #include <vector> for vector<>
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.
Description
In
RemoteConfigValueToVariant()(remote_config/src/android/remote_config_android.cc), the byte-array conversion branch passed&blob(the address of the localstd::vector<unsigned char>object on the stack) instead ofblob.data()toVariant::FromMutableBlob(). Passblob.data()soVariant::FromMutableBlob()copies from the vector's underlying byte buffer rather than reading stack memory of thestd::vectorobject.Testing
:remote_config:assembleReleasevia Gradle acrossarm64-v8a,armeabi-v7a,x86, andx86_64— passed.python3 scripts/format_code.py -git_diffand./scripts/gha/check_copyright.sh -g.Type of Change
Place an
xthe applicable box: