sqlite: clear SQLTagStore bindings · nodejs/node@ce0ca47 · GitHub
Skip to content

Commit ce0ca47

Browse files
mcollinaaduh95
authored andcommitted
sqlite: clear SQLTagStore bindings
SQLTagStore reused cached statements without clearing values bound by a previous execution. Clear bindings before binding new values and reject parameters that do not correspond to template substitutions. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: #65041 Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 4f2c634 commit ce0ca47

3 files changed

Lines changed: 78 additions & 42 deletions

File tree

src/node_sqlite.cc

Lines changed: 37 additions & 42 deletions

src/node_sqlite.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ class SQLTagStore : public BaseObject {
404404
private:
405405
static BaseObjectPtr<StatementSync> PrepareStatement(
406406
const v8::FunctionCallbackInfo<v8::Value>& args);
407+
static bool ResetAndBindStatement(
408+
Environment* env,
409+
StatementSync* stmt,
410+
const v8::FunctionCallbackInfo<v8::Value>& args);
407411
BaseObjectWeakPtr<DatabaseSync> database_;
408412
LRUCache<std::string, BaseObjectPtr<StatementSync>> sql_tags_;
409413
friend class StatementExecutionHelper;

test/parallel/test-sqlite-template-tag.js

Lines changed: 37 additions & 0 deletions

0 commit comments

Comments
 (0)