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@06b1758

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
@@ -1366,7 +1366,7 @@ changes:
13661366
database that have been added with [`ATTACH DATABASE`][] **Default:** `'main'`.
13671367
* `target` {string} Name of the target database. This can be `'main'` (the default primary database) or any other
13681368
database that have been added with [`ATTACH DATABASE`][] **Default:** `'main'`.
1369-
* `rate` {number} Number of pages to be transmitted in each batch of the backup. **Default:** `100`.
1369+
* `rate` {integer} Positive number of pages to be transmitted in each batch of the backup. **Default:** `100`.
13701370
* `progress` {Function} An optional callback function that will be called after each backup step. The argument passed
13711371
to this callback is an {Object} with `remainingPages` and `totalPages` properties, describing the current progress
13721372
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
@@ -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;
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 01402520 — 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.