GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sqlite: reject non-positive backup rates · nodejs/node@61a0463

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • sqlite.md
  • src
    • node_sqlite.cc
  • test/parallel
    • test-sqlite-backup.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/sqlite.md‎

Copy file name to clipboardExpand all lines: doc/api/sqlite.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ changes:
13261326
database that have been added with [`ATTACH DATABASE`][] **Default:** `'main'`.
13271327
* `target` {string} Name of the target database. This can be `'main'` (the default primary database) or any other
13281328
database that have been added with [`ATTACH DATABASE`][] **Default:** `'main'`.
1329-
* `rate` {number} Number of pages to be transmitted in each batch of the backup. **Default:** `100`.
1329+
* `rate` {integer} Positive number of pages to be transmitted in each batch of the backup. **Default:** `100`.
13301330
* `progress` {Function} An optional callback function that will be called after each backup step. The argument passed
13311331
to this callback is an {Object} with `remainingPages` and `totalPages` properties, describing the current progress
13321332
of the backup operation.
Collapse file

‎src/node_sqlite.cc‎

Copy file name to clipboardExpand all lines: src/node_sqlite.cc
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,12 @@ void Backup(const FunctionCallbackInfo<Value>& args) {
21802180
return;
21812181
}
21822182
rate = rate_v.As<Int32>()->Value();
2183+
if (rate <= 0) {
2184+
THROW_ERR_OUT_OF_RANGE(
2185+
env->isolate(),
2186+
"The \"options.rate\" argument must be a positive integer.");
2187+
return;
2188+
}
21832189
}
21842190

21852191
Local<Value> source_v;
Collapse file

‎test/parallel/test-sqlite-backup.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-sqlite-backup.mjs
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ describe('backup()', () => {
124124
message: 'The "options.rate" argument must be an integer.'
125125
});
126126

127+
for (const rate of [0, -1]) {
128+
t.assert.throws(() => {
129+
backup(database, 'hello.db', { rate });
130+
}, {
131+
code: 'ERR_OUT_OF_RANGE',
132+
message: 'The "options.rate" argument must be a positive integer.'
133+
});
134+
}
135+
127136
t.assert.throws(() => {
128137
backup(database, 'hello.db', {
129138
progress: 'invalid'

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.