Skip to content

Remote Config (Android): pass blob.data() to Variant::FromMutableBlob - #1993

Open
AustinBenoit wants to merge 1 commit into
mainfrom
fix/remote-config-android-blob-variant
Open

AustinBenoit wants to merge 1 commit into
mainfrom
fix/remote-config-android-blob-variant

Conversation

@AustinBenoit

Copy link
Copy Markdown
Contributor

Description

In RemoteConfigValueToVariant() (remote_config/src/android/remote_config_android.cc), 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(). Pass blob.data() so Variant::FromMutableBlob() copies from the vector's underlying byte buffer rather than reading stack memory of the std::vector object.


Testing

  • Built :remote_config:assembleRelease via Gradle across arm64-v8a, armeabi-v7a, x86, and x86_64 — passed.
  • Verified python3 scripts/format_code.py -git_diff and ./scripts/gha/check_copyright.sh -g.

Type of Change

Place an x the applicable box:

  • Bug fix.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

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().

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Lint warning: Add #include <vector> for vector<>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant