diff --git a/Cargo.lock b/Cargo.lock index 821f891b70..0f43fc4924 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2956,7 +2956,7 @@ dependencies = [ [[package]] name = "libsql-ffi" -version = "0.5.0" +version = "0.9.0" dependencies = [ "bindgen", "cc", diff --git a/Cargo.toml b/Cargo.toml index 4061e1c9cc..8107228ee2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ license = "MIT" repository = "https://github.com/tursodatabase/libsql" [workspace.dependencies] +libsql-ffi = { path = "libsql-ffi", version = "0.9.0" } libsql-sys = { path = "libsql-sys", version = "0.9.0", default-features = false } libsql-hrana = { path = "libsql-hrana", version = "0.9.0" } libsql_replication = { path = "libsql-replication", version = "0.9.0" } diff --git a/libsql-ffi/Cargo.toml b/libsql-ffi/Cargo.toml index ad1607913a..52d4a633ae 100644 --- a/libsql-ffi/Cargo.toml +++ b/libsql-ffi/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "libsql-ffi" -version = "0.5.0" -edition = "2021" -build = "build.rs" -license = "MIT" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true description = "Native bindings to libSQL" -repository = "https://github.com/tursodatabase/libsql" +build = "build.rs" exclude = ["bundled/SQLite3MultipleCiphers/build", "bundled/SQLite3MultipleCiphers/test"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/libsql-ffi/bundled/src/sqlite3.c b/libsql-ffi/bundled/src/sqlite3.c index bc401c4123..7c73a90a0a 100644 --- a/libsql-ffi/bundled/src/sqlite3.c +++ b/libsql-ffi/bundled/src/sqlite3.c @@ -65356,18 +65356,25 @@ SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, voi } if (iFrame <= mxFrame) { unsigned long frame_len = nBuf-24; - unsigned char current[frame_len]; + unsigned char *current; + + current = (unsigned char *)sqlite3MallocZero(frame_len); + if (current == NULL) { + return SQLITE_NOMEM; + } rc = pPager->wal->methods.xReadFrame(pPager->wal->pData, iFrame, frame_len, current); if (rc != SQLITE_OK) { + sqlite3_free(current); return rc; } int conflict = 0; - if (memcmp(pBuf+24, current, frame_len) != 0) { + if (memcmp((unsigned char*)pBuf+24, current, frame_len) != 0) { conflict = 1; } if (pConflict) { *pConflict = conflict; } + sqlite3_free(current); if (conflict) { return SQLITE_ERROR; } diff --git a/libsql-sqlite3/src/pager.c b/libsql-sqlite3/src/pager.c index 027aabc295..5a2278b616 100644 --- a/libsql-sqlite3/src/pager.c +++ b/libsql-sqlite3/src/pager.c @@ -7842,18 +7842,25 @@ int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, void *pBuf, unsign } if (iFrame <= mxFrame) { unsigned long frame_len = nBuf-24; - unsigned char current[frame_len]; + unsigned char *current; + + current = (unsigned char *)sqlite3MallocZero(frame_len); + if (current == NULL) { + return SQLITE_NOMEM; + } rc = pPager->wal->methods.xReadFrame(pPager->wal->pData, iFrame, frame_len, current); if (rc != SQLITE_OK) { + sqlite3_free(current); return rc; } int conflict = 0; - if (memcmp(pBuf+24, current, frame_len) != 0) { + if (memcmp((unsigned char*)pBuf+24, current, frame_len) != 0) { conflict = 1; } if (pConflict) { *pConflict = conflict; } + sqlite3_free(current); if (conflict) { return SQLITE_ERROR; } diff --git a/libsql-sys/Cargo.toml b/libsql-sys/Cargo.toml index 51e6c914a2..69839292d2 100644 --- a/libsql-sys/Cargo.toml +++ b/libsql-sys/Cargo.toml @@ -11,7 +11,7 @@ categories = ["external-ffi-bindings"] [dependencies] bytes = "1.5.0" -libsql-ffi = { version = "0.5", path = "../libsql-ffi/" } +libsql-ffi = { workspace = true } once_cell = "1.18.0" rusqlite = { workspace = true, features = ["trace"], optional = true } tracing = "0.1.37" diff --git a/vendored/rusqlite/Cargo.toml b/vendored/rusqlite/Cargo.toml index 97a6da652e..53f7f3dae8 100644 --- a/vendored/rusqlite/Cargo.toml +++ b/vendored/rusqlite/Cargo.toml @@ -109,7 +109,7 @@ fallible-iterator = "0.2" fallible-streaming-iterator = "0.1" uuid = { version = "1.0", optional = true } smallvec = "1.6.1" -libsql-ffi = { version = "0.5", path = "../../libsql-ffi" } +libsql-ffi = { workspace = true } [dev-dependencies] doc-comment = "0.3"