Skip to content
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

Incorrect Usage of SQLITE_OPEN_FILEPROTECTION_NONE in FIRMessagingRmqManager.m #12900

Closed
doganaltinbas opened this issue May 6, 2024 · 3 comments

Comments

@doganaltinbas
Copy link
Contributor

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!
@hossamm91
Copy link

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

@ncooke3
Copy link
Member

ncooke3 commented May 6, 2024

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

@ncooke3
Copy link
Member

ncooke3 commented May 7, 2024

Done via #12909. Thanks again, @doganaltinbas! This will go out in Firebase 10.27.0

@ncooke3 ncooke3 closed this as completed May 7, 2024
@firebase firebase locked and limited conversation to collaborators Jun 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants