Skip to content

Commit d8bd546

Browse files
committed
fix: prevent sending a empty remote encryption key
1 parent fd75448 commit d8bd546

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

cpp/libsql/bridge.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "bridge.h"
22
#include "DumbHostObject.h"
33
#include "SmartHostObject.h"
4+
#include "libsql.h"
45
#include "logs.h"
56
#include "utils.h"
67
#include <filesystem>
@@ -49,15 +50,20 @@ DB opsqlite_libsql_open_sync(std::string const &name,
4950
libsql_connection_t c;
5051
const char *err = nullptr;
5152

52-
libsql_config config = {.db_path = path.c_str(),
53-
.primary_url = url.c_str(),
54-
.auth_token = auth_token.c_str(),
55-
.read_your_writes = '1',
56-
.encryption_key = encryption_key.c_str(),
57-
.remote_encryption_key = remote_encryption_key.c_str(),
58-
.sync_interval = sync_interval,
59-
.with_webpki = '1',
60-
.offline = offline};
53+
libsql_config config = {
54+
.db_path = path.c_str(),
55+
.primary_url = url.c_str(),
56+
.auth_token = auth_token.c_str(),
57+
.read_your_writes = '1',
58+
.encryption_key =
59+
encryption_key.empty() ? nullptr : encryption_key.c_str(),
60+
.remote_encryption_key = remote_encryption_key.empty()
61+
? nullptr
62+
: remote_encryption_key.c_str(),
63+
.sync_interval = sync_interval,
64+
.with_webpki = '1',
65+
.offline = offline,
66+
};
6167

6268
status = libsql_open_sync_with_config(config, &db, &err);
6369
if (status != 0) {

0 commit comments

Comments
 (0)