diff options
author | stephan <stephan@noemail.net> | 2022-11-30 07:17:29 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-11-30 07:17:29 +0000 |
commit | 36a0163e40eb7097e562dfc6d12af516847de2f3 (patch) | |
tree | a1d07f4ea54db6f1e8405cedd0309cbb6ca81735 /ext/wasm/api/sqlite3-vfs-helper.js | |
parent | ad4f7828153e6b80c0fceabb1a9ece702172b836 (diff) | |
download | sqlite-36a0163e40eb7097e562dfc6d12af516847de2f3.tar.gz sqlite-36a0163e40eb7097e562dfc6d12af516847de2f3.zip |
Rename some OPFS JS files. Prevent JS bindings of sqlite3_uri_...() from performing JS-to-C-string argument conversion on their first argument, as doing so is specifically illegal.
FossilOrigin-Name: 79832808de2cbdba140ed9e0558f1502b51d131ab4315265315922cda7b748cb
Diffstat (limited to 'ext/wasm/api/sqlite3-vfs-helper.js')
-rw-r--r-- | ext/wasm/api/sqlite3-vfs-helper.js | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/ext/wasm/api/sqlite3-vfs-helper.js b/ext/wasm/api/sqlite3-vfs-helper.js index 9a15dd85f..f9d3c18c7 100644 --- a/ext/wasm/api/sqlite3-vfs-helper.js +++ b/ext/wasm/api/sqlite3-vfs-helper.js @@ -183,25 +183,37 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ `methods`, (optional) `applyArgcCheck`) properties to this.installMethods(). - If the `vfs` entry is set, its `struct` property is passed - to this.registerVfs(). The `vfs` entry may optionally have - an `asDefault` property, which gets passed as the 2nd - argument to registerVfs(). + If the `vfs` entry is set then: + + - Its `struct` property is passed to this.registerVfs(). The + `vfs` entry may optionally have an `asDefault` property, which + gets passed as the 2nd argument to registerVfs(). + + - If `struct.$zName` is falsy and the entry has a string-type + `name` property, `struct.$zName` is set to the C-string form of + that `name` value before registerVfs() is called. On success returns this object. Throws on error. */ vh.installVfs = function(opt){ let count = 0; - for(const key of ['io','vfs']){ + const propList = ['io','vfs']; + for(const key of propList){ const o = opt[key]; if(o){ ++count; this.installMethods(o.struct, o.methods, !!o.applyArgcCheck); - if('vfs'===key) this.registerVfs(o.struct, !!o.asDefault); + if('vfs'===key){ + if(!o.struct.$zName && 'string'===typeof o.name){ + o.struct.$zName = wasm.allocCString(o.name); + /* Note that we leak that C-string. */ + } + this.registerVfs(o.struct, !!o.asDefault); + } } } - if(!count) toss("Misue: installVfs() options object requires at least", - "one of 'io' or 'vfs' properties."); + if(!count) toss("Misuse: installVfs() options object requires at least", + "one of:", propList); return this; }; |