From 0771482307e896a1d73ba112f9d8eeb94a1ebf4b Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Thu, 8 Mar 2018 11:06:01 -0800 Subject: [PATCH 1/4] Version bumps for Firebase 4.10.1 (#891) --- Example/Podfile | 2 +- Firebase/Core/FIROptions.m | 2 +- FirebaseCore.podspec | 2 +- FirebaseFirestore.podspec | 2 +- Firestore/Example/Podfile | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Example/Podfile b/Example/Podfile index 0a3b784e2b4..f2163082a51 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -8,7 +8,7 @@ target 'Core_Example_iOS' do # The next line is the forcing function for the Firebase pod. The Firebase # version's subspecs should depend on the component versions in their # corresponding podspec's. - pod 'Firebase/Core', '4.10.0' + pod 'Firebase/Core', '4.10.1' target 'Core_Tests_iOS' do inherit! :search_paths diff --git a/Firebase/Core/FIROptions.m b/Firebase/Core/FIROptions.m index bbfe5c0ec20..384ef21a36c 100644 --- a/Firebase/Core/FIROptions.m +++ b/Firebase/Core/FIROptions.m @@ -43,7 +43,7 @@ NSString *const kFIRLibraryVersionID = @"4" // Major version (one or more digits) @"00" // Minor version (exactly 2 digits) - @"16" // Build number (exactly 2 digits) + @"17" // Build number (exactly 2 digits) @"000"; // Fixed "000" // Plist file name. NSString *const kServiceInfoFileName = @"GoogleService-Info"; diff --git a/FirebaseCore.podspec b/FirebaseCore.podspec index 3c6fe5918a9..eec86050e19 100644 --- a/FirebaseCore.podspec +++ b/FirebaseCore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'FirebaseCore' - s.version = '4.0.16' + s.version = '4.0.17' s.summary = 'Firebase Core for iOS' s.description = <<-DESC diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index e7d1c85659f..896dcfb16c6 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'FirebaseFirestore' - s.version = '0.10.2' + s.version = '0.10.3' s.summary = 'Google Cloud Firestore for iOS' s.description = <<-DESC diff --git a/Firestore/Example/Podfile b/Firestore/Example/Podfile index bae557637f1..71afc2ba53c 100644 --- a/Firestore/Example/Podfile +++ b/Firestore/Example/Podfile @@ -1,7 +1,7 @@ # The next line is the forcing function for the Firebase pod. The Firebase # version's subspecs should depend on the component versions in their # corresponding podspec's. -pod 'Firebase/Core', '4.10.0' +pod 'Firebase/Core', '4.10.1' use_frameworks! platform :ios, '8.0' From 622a911e23e92fa92ace690d3dd64f42f46b9686 Mon Sep 17 00:00:00 2001 From: Michael Lehenbauer Date: Thu, 8 Mar 2018 12:19:19 -0800 Subject: [PATCH 2/4] Minimal fix for b/74357976 (#890) Fixes b/74357976 which caused unauthenticated users to be unable to reach the Firestore backend and updates the changelog. --- Firestore/CHANGELOG.md | 7 +++++++ Firestore/Source/Remote/FSTDatastore.mm | 2 +- Firestore/Source/Remote/FSTStream.mm | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md index b472f0c328f..e342b803ef9 100644 --- a/Firestore/CHANGELOG.md +++ b/Firestore/CHANGELOG.md @@ -1,5 +1,12 @@ # Unreleased +# v0.10.3 +- [fixed] Fixed a regression in the 4.10.0 Firebase iOS SDK release that + prevented the SDK from communicating with the backend before successfully + authenticating via Firebase Authentication or after unauthenticating and + re-authenticating. Reads and writes would silently be executed locally + but not sent to the backend. + # v0.10.2 - [changed] When you delete a FirebaseApp, the associated Firestore instances are now also deleted (#683). diff --git a/Firestore/Source/Remote/FSTDatastore.mm b/Firestore/Source/Remote/FSTDatastore.mm index a6029ee732e..b3c1d414509 100644 --- a/Firestore/Source/Remote/FSTDatastore.mm +++ b/Firestore/Source/Remote/FSTDatastore.mm @@ -313,7 +313,7 @@ - (void)invokeRPCWithFactory:(GRPCProtoCall * (^)(void))rpcFactory [FSTDatastore prepareHeadersForRPC:rpc databaseID:&self.databaseInfo->database_id() - token:(result.is_valid() ? result.token() + token:(result.user().is_authenticated() ? result.token() : absl::string_view())]; [rpc start]; } diff --git a/Firestore/Source/Remote/FSTStream.mm b/Firestore/Source/Remote/FSTStream.mm index a9aa245ad4f..ba884727579 100644 --- a/Firestore/Source/Remote/FSTStream.mm +++ b/Firestore/Source/Remote/FSTStream.mm @@ -297,7 +297,7 @@ - (void)resumeStartWithToken:(const Token &)token error:(NSError *)error { [FSTDatastore prepareHeadersForRPC:_rpc databaseID:&self.databaseInfo->database_id() - token:(token.is_valid() ? token.token() : absl::string_view())]; + token:(token.user().is_authenticated() ? token.token() : absl::string_view())]; FSTAssert(_callbackFilter == nil, @"GRX Filter must be nil"); _callbackFilter = [[FSTCallbackFilter alloc] initWithStream:self]; [_rpc startWithWriteable:_callbackFilter]; From d44174e1d21acb265dc9d8967dea3df92799a3b8 Mon Sep 17 00:00:00 2001 From: Gil Date: Thu, 8 Mar 2018 12:36:09 -0800 Subject: [PATCH 3/4] Copy all C++ strings to NSString where they're not obviously safe (#893) This fixes a known instances of memory corruption where in FSTLevelDBMutationQueue, the NSString view was retained for later, and the incorrect user was used, causing b/74381054. gRPC does not necessarily copy its string argumnets and if our hostname were configured to a non-default one it's possible that we could corrupt the host cache too. All remaining usages of util::WrapNSStringNoCopy are obviously safe: passed into logging or other known transient usages. --- Firestore/Source/Local/FSTLevelDBMutationQueue.mm | 4 ++-- Firestore/Source/Remote/FSTDatastore.mm | 2 +- Firestore/Source/Remote/FSTSerializerBeta.mm | 4 ++-- Firestore/Source/Remote/FSTStream.mm | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Firestore/Source/Local/FSTLevelDBMutationQueue.mm b/Firestore/Source/Local/FSTLevelDBMutationQueue.mm index 248ef9a67d8..24dac60455a 100644 --- a/Firestore/Source/Local/FSTLevelDBMutationQueue.mm +++ b/Firestore/Source/Local/FSTLevelDBMutationQueue.mm @@ -94,7 +94,7 @@ @implementation FSTLevelDBMutationQueue { + (instancetype)mutationQueueWithUser:(const User &)user db:(std::shared_ptr)db serializer:(FSTLocalSerializer *)serializer { - NSString *userID = user.is_authenticated() ? util::WrapNSStringNoCopy(user.uid()) : @""; + NSString *userID = user.is_authenticated() ? util::WrapNSString(user.uid()) : @""; return [[FSTLevelDBMutationQueue alloc] initWithUserID:userID db:db serializer:serializer]; } @@ -103,7 +103,7 @@ - (instancetype)initWithUserID:(NSString *)userID db:(std::shared_ptr)db serializer:(FSTLocalSerializer *)serializer { if (self = [super init]) { - _userID = userID; + _userID = [userID copy]; _db = db; _serializer = serializer; } diff --git a/Firestore/Source/Remote/FSTDatastore.mm b/Firestore/Source/Remote/FSTDatastore.mm index b3c1d414509..ce2439b6b75 100644 --- a/Firestore/Source/Remote/FSTDatastore.mm +++ b/Firestore/Source/Remote/FSTDatastore.mm @@ -92,7 +92,7 @@ - (instancetype)initWithDatabaseInfo:(const DatabaseInfo *)databaseInfo credentials:(id)credentials { if (self = [super init]) { _databaseInfo = databaseInfo; - NSString *host = util::WrapNSStringNoCopy(databaseInfo->host()); + NSString *host = util::WrapNSString(databaseInfo->host()); if (!databaseInfo->ssl_enabled()) { GRPCHost *hostConfig = [GRPCHost hostWithAddress:host]; hostConfig.secure = NO; diff --git a/Firestore/Source/Remote/FSTSerializerBeta.mm b/Firestore/Source/Remote/FSTSerializerBeta.mm index ceb05010740..5445308748c 100644 --- a/Firestore/Source/Remote/FSTSerializerBeta.mm +++ b/Firestore/Source/Remote/FSTSerializerBeta.mm @@ -149,8 +149,8 @@ - (FSTResourcePath *)decodedQueryPath:(NSString *)name { - (FSTResourcePath *)encodedResourcePathForDatabaseID:(const DatabaseId *)databaseID { return [FSTResourcePath pathWithSegments:@[ - @"projects", util::WrapNSStringNoCopy(databaseID->project_id()), @"databases", - util::WrapNSStringNoCopy(databaseID->database_id()) + @"projects", util::WrapNSString(databaseID->project_id()), @"databases", + util::WrapNSString(databaseID->database_id()) ]]; } diff --git a/Firestore/Source/Remote/FSTStream.mm b/Firestore/Source/Remote/FSTStream.mm index ba884727579..69ce7fd70f4 100644 --- a/Firestore/Source/Remote/FSTStream.mm +++ b/Firestore/Source/Remote/FSTStream.mm @@ -629,7 +629,7 @@ - (instancetype)initWithDatabase:(const DatabaseInfo *)database } - (GRPCCall *)createRPCWithRequestsWriter:(GRXWriter *)requestsWriter { - return [[GRPCCall alloc] initWithHost:util::WrapNSStringNoCopy(self.databaseInfo->host()) + return [[GRPCCall alloc] initWithHost:util::WrapNSString(self.databaseInfo->host()) path:@"/google.firestore.v1beta1.Firestore/Listen" requestsWriter:requestsWriter]; } @@ -714,7 +714,7 @@ - (instancetype)initWithDatabase:(const DatabaseInfo *)database } - (GRPCCall *)createRPCWithRequestsWriter:(GRXWriter *)requestsWriter { - return [[GRPCCall alloc] initWithHost:util::WrapNSStringNoCopy(self.databaseInfo->host()) + return [[GRPCCall alloc] initWithHost:util::WrapNSString(self.databaseInfo->host()) path:@"/google.firestore.v1beta1.Firestore/Write" requestsWriter:requestsWriter]; } From 222285f0556e7f584a9676ae9edb7d489560b65b Mon Sep 17 00:00:00 2001 From: zxu123 Date: Thu, 8 Mar 2018 16:41:17 -0500 Subject: [PATCH 4/4] fix lint --- Firestore/Source/Remote/FSTDatastore.mm | 3 ++- Firestore/Source/Remote/FSTStream.mm | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Firestore/Source/Remote/FSTDatastore.mm b/Firestore/Source/Remote/FSTDatastore.mm index 7557c245b60..3b536abf78c 100644 --- a/Firestore/Source/Remote/FSTDatastore.mm +++ b/Firestore/Source/Remote/FSTDatastore.mm @@ -319,7 +319,8 @@ - (void)invokeRPCWithFactory:(GRPCProtoCall * (^)(void))rpcFactory [FSTDatastore prepareHeadersForRPC:rpc databaseID:&self.databaseInfo->database_id() - token:(result.user().is_authenticated() ? result.token() : absl::string_view())]; + token:(result.user().is_authenticated() ? result.token() + : absl::string_view())]; [rpc start]; } }]; diff --git a/Firestore/Source/Remote/FSTStream.mm b/Firestore/Source/Remote/FSTStream.mm index afe9cc82f7f..44e3ef01a7e 100644 --- a/Firestore/Source/Remote/FSTStream.mm +++ b/Firestore/Source/Remote/FSTStream.mm @@ -297,9 +297,10 @@ - (void)resumeStartWithToken:(const Token &)token error:(NSError *)error { _rpc = [self createRPCWithRequestsWriter:self.requestsWriter]; [_rpc setResponseDispatchQueue:self.workerDispatchQueue.queue]; - [FSTDatastore prepareHeadersForRPC:_rpc - databaseID:&self.databaseInfo->database_id() - token:(token.user().is_authenticated() ? token.token() : absl::string_view())]; + [FSTDatastore + prepareHeadersForRPC:_rpc + databaseID:&self.databaseInfo->database_id() + token:(token.user().is_authenticated() ? token.token() : absl::string_view())]; FSTAssert(_callbackFilter == nil, @"GRX Filter must be nil"); _callbackFilter = [[FSTCallbackFilter alloc] initWithStream:self]; [_rpc startWithWriteable:_callbackFilter];