Skip to content

Commit 020eb60

Browse files
authored
Simplify Serializer [En|De]code*() methods to no longer [de]serialize… (#2013)
Now, we use the re-worked nanopb deserializer (that mallocs). This also had the advantage of moving the C++ serialization code closer to the other platforms. Still TODO: - Reorder the methods within the files to resemble the other platforms.
1 parent 74d5ed8 commit 020eb60

File tree

15 files changed

+711
-1362
lines changed

15 files changed

+711
-1362
lines changed

FirebaseFirestore.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling,
5757
s.dependency 'gRPC-C++', '0.0.5'
5858
s.dependency 'leveldb-library', '~> 1.20'
5959
s.dependency 'Protobuf', '~> 3.1'
60-
s.dependency 'nanopb', '~> 0.3.8'
60+
s.dependency 'nanopb', '~> 0.3.901'
6161

6262
s.frameworks = 'MobileCoreServices', 'SystemConfiguration'
6363
s.library = 'c++'

Firestore/Example/Firestore.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,6 +2492,7 @@
24922492
"\"${PODS_ROOT}/GoogleTest/googlemock/include\"",
24932493
"\"${PODS_ROOT}/GoogleTest/googletest/include\"",
24942494
"\"${PODS_ROOT}/leveldb-library/include\"",
2495+
"\"${PODS_ROOT}/../../../Firestore/Protos/nanopb\"",
24952496
"\"${PODS_ROOT}/../../../Firestore/Protos/cpp\"",
24962497
"\"${PODS_ROOT}/ProtobufCpp/src\"",
24972498
);
@@ -2569,6 +2570,7 @@
25692570
"\"${PODS_ROOT}/GoogleTest/googlemock/include\"",
25702571
"\"${PODS_ROOT}/GoogleTest/googletest/include\"",
25712572
"\"${PODS_ROOT}/leveldb-library/include\"",
2573+
"\"${PODS_ROOT}/../../../Firestore/Protos/nanopb\"",
25722574
"\"${PODS_ROOT}/../../../Firestore/Protos/cpp\"",
25732575
"\"${PODS_ROOT}/ProtobufCpp/src\"",
25742576
);
@@ -2640,6 +2642,7 @@
26402642
"\"${PODS_ROOT}/../../..\"",
26412643
"\"${PODS_ROOT}/../../../Firestore/third_party/abseil-cpp\"",
26422644
"\"${PODS_ROOT}/nanopb\"",
2645+
"\"${PODS_ROOT}/../../../Firestore/Protos/nanopb\"",
26432646
);
26442647
INFOPLIST_FILE = "FuzzTests/Firestore_FuzzTests_iOS-Info.plist";
26452648
OTHER_CFLAGS = (
@@ -2672,6 +2675,7 @@
26722675
"\"${PODS_ROOT}/../../..\"",
26732676
"\"${PODS_ROOT}/../../../Firestore/third_party/abseil-cpp\"",
26742677
"\"${PODS_ROOT}/nanopb\"",
2678+
"\"${PODS_ROOT}/../../../Firestore/Protos/nanopb\"",
26752679
);
26762680
INFOPLIST_FILE = "FuzzTests/Firestore_FuzzTests_iOS-Info.plist";
26772681
OTHER_CFLAGS = (

Firestore/Example/FuzzTests/FuzzingTargets/FSTFuzzTestSerializer.mm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ int FuzzTestDeserialization(const uint8_t *data, size_t size) {
3838
@autoreleasepool {
3939
@try {
4040
Reader reader = Reader::Wrap(data, size);
41-
serializer.DecodeFieldValue(&reader);
41+
google_firestore_v1_Value nanopb_proto{};
42+
reader.ReadNanopbMessage(google_firestore_v1_Value_fields, &nanopb_proto);
43+
serializer.DecodeFieldValue(&reader, nanopb_proto);
4244
} @catch (...) {
4345
// Caught exceptions are ignored because the input might be malformed and
4446
// the deserialization might throw an error as intended. Fuzzing focuses on

0 commit comments

Comments
 (0)