mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
tty: validate file descriptor to avoid int32 overflow
Fixes: https://github.com/nodejs/node/issues/37805 PR-URL: https://github.com/nodejs/node/pull/37809 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
parent
3bee6d8aad
commit
134fb5a8d0
@ -40,7 +40,8 @@ const {
|
||||
let readline;
|
||||
|
||||
function isatty(fd) {
|
||||
return NumberIsInteger(fd) && fd >= 0 && isTTY(fd);
|
||||
return NumberIsInteger(fd) && fd >= 0 && fd <= 2147483647 &&
|
||||
isTTY(fd);
|
||||
}
|
||||
|
||||
function ReadStream(fd, options) {
|
||||
|
@ -10,6 +10,7 @@ strictEqual(isatty(2), true, 'stderr reported to not be a tty, but it is');
|
||||
|
||||
strictEqual(isatty(-1), false, '-1 reported to be a tty, but it is not');
|
||||
strictEqual(isatty(55555), false, '55555 reported to be a tty, but it is not');
|
||||
strictEqual(isatty(2 ** 31), false, '2^31 reported to be a tty, but it is not');
|
||||
strictEqual(isatty(1.1), false, '1.1 reported to be a tty, but it is not');
|
||||
strictEqual(isatty('1'), false, '\'1\' reported to be a tty, but it is not');
|
||||
strictEqual(isatty({}), false, '{} reported to be a tty, but it is not');
|
||||
|
Loading…
Reference in New Issue
Block a user