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
Expand file treeCollapse file tree
Open diff view settings
Collapse file
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 number | Diff line number | Diff line change |
|---|
@@ -1366,7 +1366,7 @@ changes: |
1366 | 1366 | database that have been added with [`ATTACH DATABASE`][] **Default:** `'main'`. |
1367 | 1367 | * `target` {string} Name of the target database. This can be `'main'` (the default primary database) or any other |
1368 | 1368 | 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`. |
1370 | 1370 | * `progress` {Function} An optional callback function that will be called after each backup step. The argument passed |
1371 | 1371 | to this callback is an {Object} with `remainingPages` and `totalPages` properties, describing the current progress |
1372 | 1372 | of the backup operation. |
|
Collapse file
Copy file name to clipboardExpand all lines: src/node_sqlite.cc +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2200,6 +2200,12 @@ void Backup(const FunctionCallbackInfo<Value>& args) { |
2200 | 2200 | return; |
2201 | 2201 | } |
2202 | 2202 | 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 | + } |
2203 | 2209 | } |
2204 | 2210 |
|
2205 | 2211 | Local<Value> source_v; |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-sqlite-backup.mjs +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -124,6 +124,15 @@ describe('backup()', () => { |
124 | 124 | message: 'The "options.rate" argument must be an integer.' |
125 | 125 | }); |
126 | 126 |
|
| 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 | + |
127 | 136 | t.assert.throws(() => { |
128 | 137 | backup(database, 'hello.db', { |
129 | 138 | progress: 'invalid' |
|