SIGN IN SIGN UP

libsql-ffi: Update vendored SQLite3MultipleCiphers to 1.9.0

This updates the vendored SQLite3 Multiple Ciphers encryption extension
from 1.8.1 to 1.9.0, the release that targets upstream SQLite 3.47.0 (the
base version we now ship). The previous 1.8.1 vendoring lagged the SQLite
base and was missing several upstream fixes, including a crash in
sqlite3mcSetCodec().

The import replaces all upstream files with their v1.9.0 contents and
re-applies libSQL's local patches via 3-way merge (base v1.8.1, ours
libSQL, theirs v1.9.0). All merges were clean (no conflicts), and
`cargo build -p libsql-ffi --features multiple-ciphers` builds.

== Preserved as-is (not upstream sqlite3mc) ==

src/sqlite3.c, src/sqlite3.h — libSQL's own SQLite amalgamation, not
  sqlite3mc's vanilla copy. build.rs overwrites src/sqlite3.c with
  libsql-sqlite3's amalgamation at build time regardless, so these are
  left untouched.

== Re-applied libSQL patches (3-way merged onto 1.9.0) ==

CMakeLists.txt — libSQL build options (LIBSQL_ENCRYPTION,
  LIBSQL_CUSTOM_PAGER_CODEC, LIBSQL_EXTRA_PRAGMAS,
  LIBSQL_ENABLE_WASM_RUNTIME), AES256-only cipher selection, and the
  arm/aarch64 guards around -msse4.2/-maes.

src/sqlite3mc.c — `#include "sqlite3.c"` instead of "sqlite3patched.c"
  so the amalgamation pulls in libSQL's SQLite.

src/codecext.c, src/sqlite3mc_vfs.c — libSQL codec hooks
  libsql_db_has_codec(), libsql_pager_codec_impl() (replacing
  sqlite3mcPagerHasCodec()/sqlite3mcPagerCodec()), and the cached
  hasCodec update in the rekey success path.

src/cipher_config.c — libsql_extra_pragma().
src/cipher_wxaes256.c — libsql_generate_aes256_key().
src/codec_algos.c — libsql_generate_initial_vector().

== Notable upstream fixes now picked up ==

src/sqlite3mc_vfs.c — sqlite3mcSetCodec() now passes the VFS located by
  mcFindVfs() (pVfsMC) to mcFindDbMainFileName() instead of blindly
  casting db->pVfs. When the Multiple Ciphers VFS is not the top-level
  VFS (another VFS stacked on top), db->pVfs is not an sqlite3mc_vfs and
  the cast made mcFindDbMainFileName() dereference a bogus ->mutex and
  crash. This matches the fix already present in sqlite3mcGetCodec().

src/sqlite3mc_vfs.c — the mcRead* helpers now propagate codec errors via
  sqlite3mcGetCodecLastError() instead of silently resetting rc to
  SQLITE_OK after decryption.
P
Pekka Enberg committed
eb03b043f0b6335ff33154c640dd423372a822a6
Parent: 5816145