Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7193a18
Fix: Check flatbuffer integrity before parsing
AustinBenoit Jun 3, 2026
c50d721
Handle new FBT_MAX_TYPE in flatbuffers
AustinBenoit Jun 4, 2026
dde589e
Fix the GenerateText response
AustinBenoit Jun 5, 2026
1dde56a
Patch flatbuffers to resolve ERROR macro conflict on Windows
AustinBenoit Jun 8, 2026
0202676
Add release notes
AustinBenoit Jun 8, 2026
51f3395
Restore 0001-remove-unused-var.patch for Android flatbuffers v1.12.0 …
AustinBenoit Jun 8, 2026
8938c3b
Use cp -RL on Windows to avoid symbolic link creation failure
AustinBenoit Jun 9, 2026
9850a4c
Address code review feedback on remote_config desktop implementation
AustinBenoit Jun 23, 2026
aa64115
Revert minor whitespace change in 0001-remove-unused-var.patch
AustinBenoit Jun 23, 2026
700c4f6
Add default case to FlexbufferToVariant switch to handle unknown/corr…
AustinBenoit Jun 24, 2026
b9128e1
Fix incorrect GenerateText return value comparison to nullptr
AustinBenoit Jun 24, 2026
3b6dbc8
Add default case to FlexbufferToVariant switches in app and database …
AustinBenoit Jun 24, 2026
ca07b97
Avoid leading slash in app_data_prefix when package_name is empty/null
AustinBenoit Jun 24, 2026
cf6501e
Add defensive null check for configs in RemoteConfigFileManager::Load
AustinBenoit Jun 24, 2026
9aa9d5c
Fix logic inversion in RequestJson serialization assertion
AustinBenoit Jun 24, 2026
8e06e5c
Pin flatbuffers to official v25.12.19 release commit 7e163021
AustinBenoit Jun 24, 2026
1eb093d
Unify C++ and Java FlatBuffers versions to v25.2.10
AustinBenoit Jun 24, 2026
dad5112
Update FlatBuffers patch for v25.2.10 formatting compatibility on Win…
AustinBenoit Jun 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/rest/request_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class RequestJson : public Request {
// Generate JSON string.
std::string json;
bool generate_status =
GenerateText(*parser_, builder.GetBufferPointer(), &json);
GenerateText(*parser_, builder.GetBufferPointer(), &json) == nullptr;
FIREBASE_ASSERT_RETURN_VOID(generate_status);

set_post_fields(json.c_str());
Expand Down
5 changes: 5 additions & 0 deletions app/src/variant_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ Variant FlexbufferToVariant(const flexbuffers::Reference& ref) {
case flexbuffers::FBT_BLOB:
LogError("Flexbuffers containing blobs are not supported.");
break;
case flexbuffers::FBT_MAX_TYPE:
default:
LogError("Unknown or unsupported flexbuffer type: %d",
static_cast<int>(ref.GetType()));
break;
Comment thread
AustinBenoit marked this conversation as resolved.
}
return Variant::Null();
}
Expand Down
3 changes: 1 addition & 2 deletions build_scripts/android/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,5 @@ if [[ $(uname) == "Linux" ]] || [[ $(uname) == "Darwin" ]]; then
else
# rsync has to be specifically installed on windows bash (including github runners)
# Also, rsync with absolute destination path doesn't work on Windows.
# Using a simple copy instead of rsync on Windows.
cp -R --parents "${paths[@]}" "${absbuildpath}"
cp -RL --parents "${paths[@]}" "${absbuildpath}"
fi
7 changes: 4 additions & 3 deletions cmake/external/flatbuffers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ if(TARGET flatbuffers OR NOT DOWNLOAD_FLATBUFFERS)
return()
endif()

set(version 99aa1ef21dd9dc3f9d4fb0eb82f4b59d0bb5e4c5)
# Pinned to the official v25.2.10 release commit to ensure stability and match Java library.
set(version 1c514626e83c20fffa8557e75641848e1e15cd5e)
set(patch_file
${CMAKE_CURRENT_LIST_DIR}/../../scripts/git/patches/flatbuffers/0001-remove-unused-var.patch)
${CMAKE_CURRENT_LIST_DIR}/../../scripts/git/patches/flatbuffers/0001-fix-error-macro.patch)

ExternalProject_Add(
flatbuffers
Expand All @@ -29,7 +30,7 @@ ExternalProject_Add(
COMMAND git init flatbuffers
COMMAND cd flatbuffers && git fetch --depth=1 https://github.com/google/flatbuffers.git ${version} && git reset --hard FETCH_HEAD

PATCH_COMMAND git apply ${patch_file} && git gc --aggressive
PATCH_COMMAND git apply ${patch_file}
PREFIX ${PROJECT_BINARY_DIR}

CONFIGURE_COMMAND ""
Expand Down
5 changes: 5 additions & 0 deletions database/src/desktop/persistence/flatbuffer_conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ Variant FlexbufferToVariant(const flexbuffers::Reference& ref) {
case flexbuffers::FBT_BLOB:
LogError("Flexbuffers containing blobs are not supported.");
break;
case flexbuffers::FBT_MAX_TYPE:
default:
LogError("Unknown or unsupported flexbuffer type: %d",
static_cast<int>(ref.GetType()));
break;
Comment thread
AustinBenoit marked this conversation as resolved.
}
return Variant::Null();
}
Expand Down
15 changes: 4 additions & 11 deletions messaging/messaging_java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ buildscript {
// that requires using a newer version of the JDK and at least Android N.
// This has already been fixed at head, but a tagged release is not yet
// available with that fix.
classpath 'com.google.flatbuffers:flatbuffers-java:1.12.0'
classpath 'com.google.flatbuffers:flatbuffers-java:25.2.10'
}
}
allprojects {
Expand Down Expand Up @@ -64,7 +64,7 @@ dependencies {
implementation platform('com.google.firebase:firebase-bom:34.15.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.flatbuffers:flatbuffers-java:1.12.0'
implementation 'com.google.flatbuffers:flatbuffers-java:25.2.10'
}

afterEvaluate {
Expand All @@ -81,20 +81,13 @@ afterEvaluate {
executable 'git'
args 'clone',
'--branch',
'v1.12.0',
'v25.2.10',
'--depth',
'1',
'https://github.com/google/flatbuffers.git',
flatbuffersDir
}
exec {
executable 'git'
args 'apply',
'../../scripts/git/patches/flatbuffers/0001-remove-unused-var.patch',
'--verbose',
'--directory',
'messaging/messaging_java/build/flatbuffers'
}

}

// Locate or build flatc.
Expand Down
4 changes: 4 additions & 0 deletions release_build_files/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ workflow use only during the development of your app, not for publicly shipping
code.

## Release Notes
### Upcoming
- Changes
- Remote Config (Desktop): Updated Flatbuffers to latest version to support buffer verification. Added flexbuffer integrity checks before parsing to prevent crashes on invalid/malformed data.

### 13.9.0
- Changes
- General (Android): Update to Firebase Android BoM version 34.15.0.
Expand Down
6 changes: 6 additions & 0 deletions remote_config/src/desktop/config_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ std::string NamespacedConfigData::Serialize() const {
void NamespacedConfigData::Deserialize(const std::string& buffer) {
const uint8_t* data = reinterpret_cast<const uint8_t*>(buffer.data());
size_t size = buffer.size();
if (!flexbuffers::VerifyBuffer(data, size)) {
return;
}
auto struct_map = flexbuffers::GetRoot(data, size).AsMap();
flexbuffers::Map ns_config_map = struct_map["config_"].AsMap();
for (int i = 0, in = ns_config_map.size(); i < in; ++i) {
Expand Down Expand Up @@ -144,6 +147,9 @@ std::string LayeredConfigs::Serialize() const {
void LayeredConfigs::Deserialize(const std::string& buffer) {
const uint8_t* data = reinterpret_cast<const uint8_t*>(buffer.data());
size_t size = buffer.size();
if (!flexbuffers::VerifyBuffer(data, size)) {
return;
}
auto struct_map = flexbuffers::GetRoot(data, size).AsMap();
fetched.Deserialize(struct_map["fetched"].AsString().str());
active.Deserialize(struct_map["active"].AsString().str());
Expand Down
27 changes: 23 additions & 4 deletions remote_config/src/desktop/file_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ namespace internal {

RemoteConfigFileManager::RemoteConfigFileManager(const std::string& filename,
const firebase::App& app) {
const char* package_name = app.options().package_name();
std::string app_data_prefix =
std::string(app.options().package_name()) + "/" + app.name();
std::string file_path =
AppDataDir(app_data_prefix.c_str(), /*should_create=*/true) + "/" +
filename;
(package_name && package_name[0] != '\0')
? std::string(package_name) + "/remote_config"
: "remote_config";
std::string error;
std::string app_dir =
AppDataDir(app_data_prefix.c_str(), /*should_create=*/true, &error);
std::string file_path;
if (error.empty() && !app_dir.empty()) {
file_path = app_dir + "/" + app.name() + "_" + filename;
}
#if FIREBASE_PLATFORM_WINDOWS
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> utf8_to_wstring;
file_path_ = utf8_to_wstring.from_bytes(file_path);
Expand All @@ -50,16 +57,28 @@ RemoteConfigFileManager::RemoteConfigFileManager(const std::string& filename,
}

bool RemoteConfigFileManager::Load(LayeredConfigs* configs) const {
if (!configs || file_path_.empty()) {
return false;
}
std::fstream input(file_path_, std::ios::in | std::ios::binary);
if (!input) {
return false;
}
std::stringstream ss;
ss << input.rdbuf();
configs->Deserialize(ss.str());
return true;
}

bool RemoteConfigFileManager::Save(const LayeredConfigs& configs) const {
if (file_path_.empty()) {
return false;
}
std::string buffer = configs.Serialize();
std::fstream output(file_path_, std::ios::out | std::ios::binary);
if (!output) {
return false;
}
output.write(buffer.c_str(), buffer.size());
return true;
}
Expand Down
20 changes: 19 additions & 1 deletion remote_config/src/desktop/metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

#include "remote_config/src/desktop/metadata.h"

#include <cerrno>
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <map>
#include <string>
Comment thread
AustinBenoit marked this conversation as resolved.

Expand Down Expand Up @@ -59,6 +62,9 @@ std::string RemoteConfigMetadata::Serialize() const {
void RemoteConfigMetadata::Deserialize(const std::string& buffer) {
const uint8_t* data = reinterpret_cast<const uint8_t*>(buffer.data());
size_t size = buffer.size();
if (!flexbuffers::VerifyBuffer(data, size)) {
return;
}
auto struct_map = flexbuffers::GetRoot(data, size).AsMap();

flexbuffers::Map info = struct_map["info"].AsMap();
Expand All @@ -76,7 +82,19 @@ void RemoteConfigMetadata::Deserialize(const std::string& buffer) {
settings_.clear();
flexbuffers::Map settings = struct_map["settings"].AsMap();
for (int i = 0, n = settings.size(); i < n; ++i) {
int int_key = std::stoi(settings.Keys()[i].AsKey());
const char* key_str = settings.Keys()[i].AsKey();
if (!key_str) continue;
char* endptr = nullptr;
errno = 0;
long raw_key = std::strtol(key_str, &endptr, 10);
if (endptr == key_str || *endptr != '\0' || errno == ERANGE) {
continue;
}
if (raw_key < std::numeric_limits<int>::min() ||
raw_key > std::numeric_limits<int>::max()) {
continue;
}
Comment thread
AustinBenoit marked this conversation as resolved.
int int_key = static_cast<int>(raw_key);
settings_[static_cast<ConfigSetting>(int_key)] =
settings.Values()[i].AsString().c_str();
}
Expand Down
5 changes: 5 additions & 0 deletions remote_config/src/desktop/remote_config_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ Variant FlexbufferToVariant(const flexbuffers::Reference& ref) {
case flexbuffers::FBT_BLOB:
LogError("Flexbuffers containing blobs are not supported.");
break;
case flexbuffers::FBT_MAX_TYPE:
default:
LogError("Unknown or unsupported flexbuffer type: %d",
static_cast<int>(ref.GetType()));
break;
Comment thread
AustinBenoit marked this conversation as resolved.
}
return Variant::Null();
}
Expand Down
35 changes: 35 additions & 0 deletions scripts/git/patches/flatbuffers/0001-fix-error-macro.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From: Antigravity <antigravity@google.com>
Subject: Patch flatbuffers to resolve ERROR macro conflict on Windows

Workaround for conflict between ProtoIdGapAction::ERROR in idl.h and the
Windows global ERROR macro defined in wingdi.h/windows.h.

See Flatbuffers Issue: https://github.com/google/flatbuffers/issues/8483

diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h
index 95fda8c2..6da1c6e3 100644
--- a/include/flatbuffers/idl.h
+++ b/include/flatbuffers/idl.h
@@ -17,6 +17,12 @@
#ifndef FLATBUFFERS_IDL_H_
#define FLATBUFFERS_IDL_H_

+#ifdef ERROR
+#pragma push_macro("ERROR")
+#undef ERROR
+#define FLATBUFFERS_POP_ERROR_MACRO
+#endif
+
#include <algorithm>
#include <functional>
#include <map>
@@ -1300,4 +1306,9 @@ extern bool GenerateTSGRPC(const Parser &parser, const std::string &path,
const std::string &file_name);
} // namespace flatbuffers

+#ifdef FLATBUFFERS_POP_ERROR_MACRO
+#pragma pop_macro("ERROR")
+#undef FLATBUFFERS_POP_ERROR_MACRO
+#endif
+
#endif // FLATBUFFERS_IDL_H_
32 changes: 0 additions & 32 deletions scripts/git/patches/flatbuffers/0001-remove-unused-var.patch

This file was deleted.

Loading