Skip to content

Commit c5d9415

Browse files
authored
V2025.9.3 (#85)
* fix: Database encryption * feat: Update vcpkg
1 parent fd4e142 commit c5d9415

File tree

9 files changed

+46
-17
lines changed

9 files changed

+46
-17
lines changed

.github/workflows/linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ jobs:
5151
with:
5252
pkgs: boost-json cpr gettext-libintl glib gtest libsecret maddy
5353
triplet: ${{ matrix.variant.triplet }}
54-
revision: b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01
54+
revision: 29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
5555
token: ${{ github.token }}
56-
cache-key: ${{ matrix.variant.triplet }}-b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01
56+
cache-key: ${{ matrix.variant.triplet }}-29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
5757
- name: "Build"
5858
working-directory: ${{github.workspace}}/build
5959
run: |

.github/workflows/macos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
with:
3232
pkgs: boost-json cpr gettext-libintl glib gtest maddy
3333
triplet: arm64-osx
34-
revision: b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01
34+
revision: 29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
3535
token: ${{ github.token }}
36-
cache-key: "arm64-osx-b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01"
36+
cache-key: "arm64-osx-29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c"
3737
- name: "Build"
3838
working-directory: ${{github.workspace}}/build
3939
run: |

.github/workflows/windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
with:
3939
pkgs: boost-json cpr gettext-libintl gtest maddy sqlcipher
4040
triplet: ${{ matrix.variant.triplet }}
41-
revision: b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01
41+
revision: 29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
4242
token: ${{ github.token }}
43-
cache-key: ${{ matrix.variant.triplet }}-b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01
43+
cache-key: ${{ matrix.variant.triplet }}-29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
4444
- name: "Build"
4545
working-directory: ${{github.workspace}}/build
4646
run: |

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 2025.9.3
4+
### Breaking Changes
5+
None
6+
### New APIs
7+
None
8+
### Fixes
9+
#### Database
10+
- Fixed an issue where the sqlite database did not encrypt and decrypt correctly
11+
312
## 2025.9.2
413
### Breaking Changes
514
None

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ endif()
2020
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
2121

2222
#libnick Definition
23-
project ("libnick" LANGUAGES C CXX VERSION 2025.9.2 DESCRIPTION "A cross-platform base for native Nickvision applications.")
23+
project ("libnick" LANGUAGES C CXX VERSION 2025.9.3 DESCRIPTION "A cross-platform base for native Nickvision applications.")
2424
include(CMakePackageConfigHelpers)
2525
include(GNUInstallDirs)
2626
include(CTest)

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = "libnick"
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = "2025.9.2"
51+
PROJECT_NUMBER = "2025.9.3"
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

include/database/sqlitedatabase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ namespace Nickvision::Database
141141
};
142142
}
143143

144-
#endif //SQLDATABASE_H
144+
#endif //SQLDATABASE_H

manual/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
libnick provides Nickvision apps with a common set of cross-platform APIs for managing system and desktop app functionality such as network management, taskbar icons, translations, app updates, and more.
88

9-
## 2025.9.2
9+
## 2025.9.3
1010
### Breaking Changes
1111
None
1212
### New APIs
1313
None
1414
### Fixes
15-
#### Helpers
16-
- Fixed a deadlock in `JsonFileBase`
15+
#### Database
16+
- Fixed an issue where the sqlite database did not encrypt and decrypt correctly
1717

1818
## Dependencies
1919
The following are a list of dependencies used by libnick.

src/database/sqlitedatabase.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Nickvision::Database
1414
{
1515
throw std::runtime_error("Unable to open sql database.");
1616
}
17-
if(sqlite3_exec(m_database, "PRAGMA schema_version", nullptr, nullptr, nullptr) != SQLITE_OK)
17+
if(sqlite3_exec(m_database, "SELECT count(*) FROM sqlite_master;", nullptr, nullptr, nullptr) != SQLITE_OK)
1818
{
1919
m_isEncrypted = true;
2020
m_isUnlocked = false;
@@ -82,7 +82,7 @@ namespace Nickvision::Database
8282
}
8383
else
8484
{
85-
m_isUnlocked = sqlite3_exec(m_database, "PRAGMA schema_version", nullptr, nullptr, nullptr) == SQLITE_OK;
85+
m_isUnlocked = sqlite3_exec(m_database, "SELECT count(*) FROM sqlite_master;", nullptr, nullptr, nullptr) == SQLITE_OK;
8686
}
8787
return m_isUnlocked;
8888
}
@@ -101,9 +101,29 @@ namespace Nickvision::Database
101101
{
102102
return true;
103103
}
104+
//If empty database, can use sqlite3_key
105+
SqliteStatement statement{ m_database, "SELECT count(*) FROM sqlite_master;" };
106+
int tableCount{ -1 };
107+
if(statement.step() == SqliteStepResult::Row)
108+
{
109+
tableCount = statement.getColumn<int>(0);
110+
}
111+
if(tableCount == 0)
112+
{
113+
if(sqlite3_key(m_database, password.c_str(), static_cast<int>(password.size())) != SQLITE_OK)
114+
{
115+
return false;
116+
}
117+
else
118+
{
119+
m_isUnlocked = sqlite3_exec(m_database, "SELECT count(*) FROM sqlite_master;", nullptr, nullptr, nullptr) == SQLITE_OK;
120+
m_isEncrypted = true;
121+
return true;
122+
}
123+
}
104124
//Create temp encrypted database
105125
std::filesystem::path tempPath{ (m_path.string() + ".encrypt") };
106-
std::string cmd{ "ATTACH DATABASE '" + tempPath.string() + "' AS encrypted KEY '" + password + "'" };
126+
std::string cmd{ "ATTACH DATABASE '" + tempPath.string() + "' AS encrypted KEY '" + password + "'" };
107127
sqlite3_exec(m_database, cmd.c_str(), nullptr, nullptr, nullptr);
108128
sqlite3_exec(m_database, "SELECT sqlcipher_export('encrypted')", nullptr, nullptr, nullptr);
109129
sqlite3_exec(m_database, "DETACH DATABASE encrypted", nullptr, nullptr, nullptr);
@@ -120,7 +140,7 @@ namespace Nickvision::Database
120140
{
121141
throw std::runtime_error("Unable to open sql database with password.");
122142
}
123-
m_isUnlocked = sqlite3_exec(m_database, "PRAGMA schema_version", nullptr, nullptr, nullptr) == SQLITE_OK;
143+
m_isUnlocked = sqlite3_exec(m_database, "SELECT count(*) FROM sqlite_master;", nullptr, nullptr, nullptr) == SQLITE_OK;
124144
m_isEncrypted = true;
125145
return true;
126146
}
@@ -202,4 +222,4 @@ namespace Nickvision::Database
202222
}
203223
return *this;
204224
}
205-
}
225+
}

0 commit comments

Comments
 (0)