diff options
author | Robert Relyea <rrelyea@redhat.com> | 2021-07-20 14:17:47 -0700 |
---|---|---|
committer | Robert Relyea <rrelyea@redhat.com> | 2021-07-20 14:17:47 -0700 |
commit | e154588a5dedfca47cd0bf75261f6b73cdd0795d (patch) | |
tree | 32dcaa0ebb94ebe2260bc172da880386d4880bd2 /lib/softoken | |
parent | dbb32786e08ca7cf654a7631dd525c9768d0d9b6 (diff) | |
download | nss-hg-e154588a5dedfca47cd0bf75261f6b73cdd0795d.tar.gz |
Bug 1721476 sqlite 3.34 changed it's open semantics, causing nss failures.
https://sqlite.org/forum/info/42cf8e985bb051a2
sqlite is now permissive on opening a readonly file even if you ask for the file to be opened R/W.
normally sqlite is very conservative in changing it's underlying semantics, but evidently they chose convience over compatibility. NSS now needs to check the file permissions itself to preserve nss semantics.
Differential Revision: https://phabricator.services.mozilla.com/D120406
Diffstat (limited to 'lib/softoken')
-rw-r--r-- | lib/softoken/sdb.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/softoken/sdb.c b/lib/softoken/sdb.c index 4083f3244..548cf4253 100644 --- a/lib/softoken/sdb.c +++ b/lib/softoken/sdb.c @@ -690,6 +690,11 @@ sdb_openDB(const char *name, sqlite3 **sqlDB, int flags) openFlags = SQLITE_OPEN_READONLY; } else { openFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; + /* sqlite 3.34 seem to incorrectly open readwrite. + * when the file is readonly. Explicitly reject that issue here */ + if ((_NSSUTIL_Access(name, PR_ACCESS_EXISTS) == PR_SUCCESS) && (_NSSUTIL_Access(name, PR_ACCESS_WRITE_OK) != PR_SUCCESS)) { + return SQLITE_READONLY; + } } /* Requires SQLite 3.5.0 or newer. */ |