| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 36e5100 commit db0bb52
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,6 +86,7 @@ const { | |||
| 86 | 86 | isUint32, | |
| 87 | 87 | validateAndMaskMode, | |
| 88 | 88 | validateInteger, | |
| 89 | + validateInt32, | ||
| 89 | 90 | validateUint32 | |
| 90 | 91 | } = require('internal/validators'); | |
| 91 | 92 | ||
@@ -1054,7 +1055,7 @@ fs.unlinkSync = function(path) { | |||
| 1054 | 1055 | }; | |
| 1055 | 1056 | ||
| 1056 | 1057 | fs.fchmod = function(fd, mode, callback) { | |
| 1057 | - validateUint32(fd, 'fd'); | ||
| 1058 | + validateInt32(fd, 'fd', 0); | ||
| 1058 | 1059 | mode = validateAndMaskMode(mode, 'mode'); | |
| 1059 | 1060 | callback = makeCallback(callback); | |
| 1060 | 1061 | ||
@@ -1064,7 +1065,7 @@ fs.fchmod = function(fd, mode, callback) { | |||
| 1064 | 1065 | }; | |
| 1065 | 1066 | ||
| 1066 | 1067 | fs.fchmodSync = function(fd, mode) { | |
| 1067 | - validateUint32(fd, 'fd'); | ||
| 1068 | + validateInt32(fd, 'fd', 0); | ||
| 1068 | 1069 | mode = validateAndMaskMode(mode, 'mode'); | |
| 1069 | 1070 | const ctx = {}; | |
| 1070 | 1071 | binding.fchmod(fd, mode, undefined, ctx); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,12 +35,21 @@ const fs = require('fs'); | |||
| 35 | 35 | const errObj = { | |
| 36 | 36 | code: 'ERR_OUT_OF_RANGE', | |
| 37 | 37 | name: 'RangeError [ERR_OUT_OF_RANGE]', | |
| 38 | - message: 'The value of "fd" is out of range. It must be >= 0 && < ' + | ||
| 39 | - `${2 ** 32}. Received ${input}` | ||
| 38 | + message: 'The value of "fd" is out of range. It must be >= 0 && <= ' + | ||
| 39 | + `2147483647. Received ${input}` | ||
| 40 | 40 | }; | |
| 41 | 41 | assert.throws(() => fs.fchmod(input), errObj); | |
| 42 | 42 | assert.throws(() => fs.fchmodSync(input), errObj); | |
| 43 | - errObj.message = errObj.message.replace('fd', 'mode'); | ||
| 43 | + }); | ||
| 44 | + | ||
| 45 | + [-1, 2 ** 32].forEach((input) => { | ||
| 46 | + const errObj = { | ||
| 47 | + code: 'ERR_OUT_OF_RANGE', | ||
| 48 | + name: 'RangeError [ERR_OUT_OF_RANGE]', | ||
| 49 | + message: 'The value of "mode" is out of range. It must be >= 0 && < ' + | ||
| 50 | + `4294967296. Received ${input}` | ||
| 51 | + }; | ||
| 52 | + | ||
| 44 | 53 | assert.throws(() => fs.fchmod(1, input), errObj); | |
| 45 | 54 | assert.throws(() => fs.fchmodSync(1, input), errObj); | |
| 46 | 55 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments