GeezerVison is showing github.com — tty: validate file descriptor to avoid int32 overflow · nodejs/node@d89d55a
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: lib/tty.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,7 +40,8 @@ const { |
40 | 40 | let readline; |
41 | 41 |
|
42 | 42 | function isatty(fd) { |
43 | | - return NumberIsInteger(fd) && fd >= 0 && isTTY(fd); |
| 43 | + return NumberIsInteger(fd) && fd >= 0 && fd <= 2147483647 && |
| 44 | + isTTY(fd); |
44 | 45 | } |
45 | 46 |
|
46 | 47 | function ReadStream(fd, options) { |
|
Collapse file
Copy file name to clipboardExpand all lines: test/pseudo-tty/test-tty-isatty.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,6 +10,7 @@ strictEqual(isatty(2), true, 'stderr reported to not be a tty, but it is'); |
10 | 10 |
|
11 | 11 | strictEqual(isatty(-1), false, '-1 reported to be a tty, but it is not'); |
12 | 12 | strictEqual(isatty(55555), false, '55555 reported to be a tty, but it is not'); |
| 13 | +strictEqual(isatty(2 ** 31), false, '2^31 reported to be a tty, but it is not'); |
13 | 14 | strictEqual(isatty(1.1), false, '1.1 reported to be a tty, but it is not'); |
14 | 15 | strictEqual(isatty('1'), false, '\'1\' reported to be a tty, but it is not'); |
15 | 16 | strictEqual(isatty({}), false, '{} reported to be a tty, but it is not'); |
|