Skip to content

Commit 59f6d08

Browse files
authored
ext/posix: posix_isatty() fix use-of-uninitialized-value (#11676)
When the value passed is not representable as an int then it is not a TTY and thus should return false immediately. This was reported by MSAN.
1 parent b79d988 commit 59f6d08

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

ext/posix/posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ PHP_FUNCTION(posix_isatty)
516516
if (!zend_parse_arg_long(z_fd, &fd, /* is_null */ NULL, /* check_null */ false, /* arg_num */ 1)) {
517517
php_error_docref(NULL, E_WARNING, "Argument #1 ($file_descriptor) must be of type int|resource, %s given",
518518
zend_zval_value_name(z_fd));
519-
fd = zval_get_long(z_fd);
519+
RETURN_FALSE;
520520
}
521521
}
522522

ext/posix/tests/posix_isatty_manual_zpp.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,9 @@ Warning: posix_isatty(): Argument #1 ($file_descriptor) must be of type int|reso
5858
bool(false)
5959
class:
6060
Warning: posix_isatty(): Argument #1 ($file_descriptor) must be of type int|resource, stdClass given in %s on line %d
61-
62-
Warning: Object of class stdClass could not be converted to int in %s on line %d
6361
bool(false)
6462
stringable class:
6563
Warning: posix_isatty(): Argument #1 ($file_descriptor) must be of type int|resource, classWithToString given in %s on line %d
66-
67-
Warning: Object of class classWithToString could not be converted to int in %s on line %d
6864
bool(false)
6965
int castable class:
7066
Warning: posix_isatty(): Argument #1 ($file_descriptor) must be of type int|resource, GMP given in %s on line %d

0 commit comments

Comments
 (0)