firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Incorrect Usage of SQLITE_OPEN_FILEPROTECTION_NONE in FIRMessagingRmqManager.m

Open doganaltinbas opened this issue 9 months ago • 2 comments

Description

Description: In the method - (void)openDatabase within the file FIRMessagingRmqManager.m, the constant SQLITE_OPEN_FILEPROTECTION_NONE is erroneously passed to the function sqlite3_open_v2(...). This issue is akin to the problem reported for Remote Config in issue #10884 and has now surfaced in the Messaging module. Notably, SQLITE_OPEN_FILEPROTECTION_NONE is not a standard flag provided by SQLite; rather, it's specific to Apple's version of SQLite and has not been merged into the main repository.

Current Implementation: The following line in the FIRMessagingRmqManager.m,

      int result = sqlite3_open_v2(
          [path UTF8String], &self -> _database,
          SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FILEPROTECTION_NONE, NULL);

Proposed Solution: To address this issue, the following modifications can be made to the FIRMessagingRmqManager.m file: Replace the existing line with the following lines:

        int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
    #ifdef SQLITE_OPEN_FILEPROTECTION_NONE
        flags |= SQLITE_OPEN_FILEPROTECTION_NONE;
    #endif
        
        int result = sqlite3_open_v2(
            [path UTF8String], &self -> _database, flags, NULL);

This solution mirrors the approach(#12548) implemented for issue #10884 and ensures compatibility with both Apple's SQLite version and the main repository.

Reproducing the issue

No response

Firebase SDK Version

10.25.0

Xcode Version

15.3

Installation Method

Swift Package Manager

Firebase Product(s)

Messaging

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

Replace this line with the contents of your Podfile.lock!

doganaltinbas avatar May 06 '24 07:05 doganaltinbas

@morganchen12 @paulb777 Can you help us with this issue? Let us know if we can contribute to fix it.

hossamm91 avatar May 06 '24 18:05 hossamm91

Yes, the proposed solution looks reasonable to me and you're welcome to open a PR for this if you'd like.

ncooke3 avatar May 06 '24 19:05 ncooke3

Done via https://github.com/firebase/firebase-ios-sdk/pull/12909. Thanks again, @doganaltinbas! This will go out in Firebase 10.27.0

ncooke3 avatar May 07 '24 21:05 ncooke3