From 2b6404574b9b94d67fc95bf28bdc157d24adfc96 Mon Sep 17 00:00:00 2001 From: Nick Cooke <36927374+ncooke3@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:54:33 -0400 Subject: [PATCH 1/2] [Auth] Use native Swift types in Auth backend types --- .../Sources/Swift/Backend/AuthBackend.swift | 15 ++++++--------- .../Tests/Unit/Fakes/FakeBackendRPCIssuer.swift | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/FirebaseAuth/Sources/Swift/Backend/AuthBackend.swift b/FirebaseAuth/Sources/Swift/Backend/AuthBackend.swift index f84a87d3e07..444a97c1c07 100644 --- a/FirebaseAuth/Sources/Swift/Backend/AuthBackend.swift +++ b/FirebaseAuth/Sources/Swift/Backend/AuthBackend.swift @@ -22,7 +22,7 @@ import Foundation #endif @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) -protocol AuthBackendRPCIssuer: NSObjectProtocol { +protocol AuthBackendRPCIssuer { /// Asynchronously send a HTTP request. /// - Parameter request: The request to be made. /// - Parameter body: Request body. @@ -35,10 +35,10 @@ protocol AuthBackendRPCIssuer: NSObjectProtocol { } @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) -class AuthBackendRPCIssuerImplementation: NSObject, AuthBackendRPCIssuer { +class AuthBackendRPCIssuerImplementation: AuthBackendRPCIssuer { let fetcherService: GTMSessionFetcherService - override init() { + init() { fetcherService = GTMSessionFetcherService() fetcherService.userAgent = AuthBackend.authUserAgent() fetcherService.callbackQueue = kAuthGlobalWorkQueue @@ -71,7 +71,7 @@ class AuthBackendRPCIssuerImplementation: NSObject, AuthBackendRPCIssuer { } @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) -class AuthBackend: NSObject { +class AuthBackend { static func authUserAgent() -> String { return "FirebaseAuth.iOS/\(FirebaseVersion()) \(GTMFetcherStandardUserAgentString(nil))" } @@ -143,11 +143,8 @@ protocol AuthBackendImplementation { } @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) -private class AuthBackendRPCImplementation: NSObject, AuthBackendImplementation { - var rpcIssuer: AuthBackendRPCIssuer - override init() { - rpcIssuer = AuthBackendRPCIssuerImplementation() - } +private class AuthBackendRPCImplementation: AuthBackendImplementation { + var rpcIssuer: AuthBackendRPCIssuer = AuthBackendRPCIssuerImplementation() /// Calls the RPC using HTTP request. /// Possible error responses: diff --git a/FirebaseAuth/Tests/Unit/Fakes/FakeBackendRPCIssuer.swift b/FirebaseAuth/Tests/Unit/Fakes/FakeBackendRPCIssuer.swift index b6ec2c13ffa..f1b4cee7a5d 100644 --- a/FirebaseAuth/Tests/Unit/Fakes/FakeBackendRPCIssuer.swift +++ b/FirebaseAuth/Tests/Unit/Fakes/FakeBackendRPCIssuer.swift @@ -23,7 +23,7 @@ import XCTest response, and glue logic. */ @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) -class FakeBackendRPCIssuer: NSObject, AuthBackendRPCIssuer { +class FakeBackendRPCIssuer: AuthBackendRPCIssuer { /** @property requestURL @brief The URL which was requested. */ From 86420a36fe57627ac2bb6dcf7ed152d39ec1b1cf Mon Sep 17 00:00:00 2001 From: Nick Cooke <36927374+ncooke3@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:09:56 -0400 Subject: [PATCH 2/2] Add changelog entry --- FirebaseAuth/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FirebaseAuth/CHANGELOG.md b/FirebaseAuth/CHANGELOG.md index 60e625d55de..57a5987609d 100644 --- a/FirebaseAuth/CHANGELOG.md +++ b/FirebaseAuth/CHANGELOG.md @@ -2,6 +2,9 @@ - [Fixed] Restore Firebase 10 behavior by querying with the `kSecAttrSynchronizable` key when auth state is set to be shared across devices. (#13584) +- [Fixed] Prevent a bad memory access crash by using non-ObjC, native Swift + types in the SDK's networking layer, and moving synchronous work off of + the shared Swift concurrency queue. (#13650) # 11.2.0 - [Fixed] Fixed crashes that could occur in Swift continuation blocks running in the Xcode 16