mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Fix SQLite WAL-reset corruption exposure
Codex uses pooled WAL-mode SQLite state databases, and the bundled SQLite 3.46.0 is affected by the documented WAL-reset corruption race. Bundle fixed SQLite 3.51.3 through a pinned libsqlite3-sys override and guard the linked runtime version in codex-state tests.
This commit is contained in:
@@ -569,6 +569,36 @@ mod tests {
|
||||
let _ = tokio::fs::remove_dir_all(codex_home).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn linked_sqlite_has_wal_reset_bug_fix() {
|
||||
let pool = SqlitePool::connect("sqlite::memory:")
|
||||
.await
|
||||
.expect("open in-memory sqlite db");
|
||||
let sqlite_version: String = sqlx::query_scalar("SELECT sqlite_version()")
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.expect("query linked sqlite version");
|
||||
pool.close().await;
|
||||
|
||||
let version = sqlite_version
|
||||
.split('.')
|
||||
.map(|part| part.parse::<u32>().expect("numeric sqlite version"))
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
version.len(),
|
||||
3,
|
||||
"unexpected SQLite version: {sqlite_version}"
|
||||
);
|
||||
let version = (version[0], version[1], version[2]);
|
||||
let includes_wal_reset_fix = version >= (3, 51, 3)
|
||||
|| (version.0 == 3 && version.1 == 50 && version.2 >= 7)
|
||||
|| (version.0 == 3 && version.1 == 44 && version.2 >= 6);
|
||||
assert!(
|
||||
includes_wal_reset_fix,
|
||||
"linked SQLite {sqlite_version} is vulnerable to the WAL-reset corruption bug"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn open_state_sqlite_tolerates_newer_applied_migrations() {
|
||||
let codex_home = unique_temp_dir();
|
||||
|
||||
Reference in New Issue
Block a user