sqlite: reject non-positive backup rates · nodejs/node@06b1758 · GitHub
Skip to content

Commit 06b1758

Browse files
trivikraduh95
authored andcommitted
sqlite: reject non-positive backup rates
Passing a rate of 0 to backup() causes sqlite3_backup_step() to copy no pages. The backup job then continually reschedules itself and the returned promise never settles. Require backup rates to be positive integers to prevent zero-work backup jobs. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: codex:gpt-5.6-sol PR-URL: #64893 Fixes: #64892 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent aa3b598 commit 06b1758

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

doc/api/sqlite.md

Lines changed: 1 addition & 1 deletion

src/node_sqlite.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,12 @@ void Backup(const FunctionCallbackInfo<Value>& args) {
22002200
return;
22012201
}
22022202
rate = rate_v.As<Int32>()->Value();
2203+
if (rate <= 0) {
2204+
THROW_ERR_OUT_OF_RANGE(
2205+
env->isolate(),
2206+
"The \"options.rate\" argument must be a positive integer.");
2207+
return;
2208+
}
22032209
}
22042210

22052211
Local<Value> source_v;

test/parallel/test-sqlite-backup.mjs

Lines changed: 9 additions & 0 deletions

0 commit comments

Comments
 (0)