You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
localStorage: a malformed backing file aborts the process via CHECK #65878
src/node_webstorage.cc asserts the SQLite type of every column it reads, but the backing file is a user-specified path. Node's own tables are STRICT, but the DDL is CREATE TABLE IF NOT EXISTS, so a file that already contains tables of those names is adopted as-is, STRICT or not.
// craft.cjsconst{ DatabaseSync }=require('node:sqlite');constout='/tmp/ws.db';for(constsof['','-wal','-shm'])require('node:fs').rmSync(out+s,{force: true});// Node's schema, minus STRICT. BLOB has no affinity, so a TEXT value stays TEXT.constdb=newDatabaseSync(out);db.exec(` CREATE TABLE nodejs_webstorage( key BLOB NOT NULL, value BLOB NOT NULL, PRIMARY KEY(key)); CREATE TABLE nodejs_webstorage_state( max_size INTEGER NOT NULL DEFAULT 10485760, total_size INTEGER NOT NULL, schema_version INTEGER NOT NULL DEFAULT 1, single_row_ INTEGER NOT NULL DEFAULT 1 CHECK(single_row_ = 1), PRIMARY KEY(single_row_));`);// A real UTF-16LE key, so that lookups still match; only the value is TEXT.db.prepare('INSERT INTO nodejs_webstorage (key, value) VALUES (?, ?)').run(Buffer.from('greeting','utf16le'),'hello');db.prepare('INSERT INTO nodejs_webstorage_state (total_size, schema_version)'+' VALUES (0, 1)').run();db.close();
Separately, line 187 re-runs init_sql_v0 and overwrites the result of the sqlite3_prepare_v2() five lines above it, so prepare failures go unreported. Given a nodejs_webstorage_state table with no schema_version column, the real error is replaced by Error: bad parameter or other API misuse.
Activity
src: throw on a malformed localStorage file
src: throw on a malformed localStorage file
src: throw on a malformed localStorage file
src: throw on a malformed localStorage file