-
Notifications
You must be signed in to change notification settings - Fork 137
Fix: Check flatbuffer integrity before parsing #1864
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
Open
AustinBenoit
wants to merge
19
commits into
main
Choose a base branch
from
FixVulns
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+113
−58
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
54f55b6
Fix: Check flatbuffer integrity before parsing
AustinBenoit 364b9e9
Handle new FBT_MAX_TYPE in flatbuffers
AustinBenoit 7a16243
Fix the GenerateText response
AustinBenoit 10f6f1b
Patch flatbuffers to resolve ERROR macro conflict on Windows
AustinBenoit ad3c3ff
Add release notes
AustinBenoit 6f19a9c
Restore 0001-remove-unused-var.patch for Android flatbuffers v1.12.0 …
AustinBenoit d0e84e7
Use cp -RL on Windows to avoid symbolic link creation failure
AustinBenoit 2ea0d93
Address code review feedback on remote_config desktop implementation
AustinBenoit bf75e94
Revert minor whitespace change in 0001-remove-unused-var.patch
AustinBenoit 5966154
Add default case to FlexbufferToVariant switch to handle unknown/corr…
AustinBenoit c27f1a3
Fix incorrect GenerateText return value comparison to nullptr
AustinBenoit 4b9896e
Add default case to FlexbufferToVariant switches in app and database …
AustinBenoit 03650c8
Avoid leading slash in app_data_prefix when package_name is empty/null
AustinBenoit 54bce01
Add defensive null check for configs in RemoteConfigFileManager::Load
AustinBenoit 163e0c0
Fix logic inversion in RequestJson serialization assertion
AustinBenoit 41abc42
Pin flatbuffers to official v25.12.19 release commit 7e163021
AustinBenoit 5d8716b
Unify C++ and Java FlatBuffers versions to v25.2.10
AustinBenoit fd2f3f1
Update FlatBuffers patch for v25.2.10 formatting compatibility on Win…
AustinBenoit 9494b44
Update Release Notes in readme.md for FlatBuffers v25.2.10 upgrade
AustinBenoit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,10 @@ | |
|
|
||
| #include "remote_config/src/desktop/metadata.h" | ||
|
|
||
| #include <cerrno> | ||
| #include <cstdint> | ||
| #include <cstdlib> | ||
| #include <limits> | ||
| #include <map> | ||
| #include <string> | ||
|
AustinBenoit marked this conversation as resolved.
|
||
|
|
||
|
|
@@ -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(); | ||
|
|
@@ -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); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 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; | ||
| } | ||
|
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(); | ||
| } | ||
|
|
||
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
35 changes: 35 additions & 0 deletions
35
scripts/git/patches/flatbuffers/0001-fix-error-macro.patch
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
| 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
32
scripts/git/patches/flatbuffers/0001-remove-unused-var.patch
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.