Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ PHP_FUNCTION(posix_ttyname)
if (!zend_parse_arg_long(z_fd, &fd, /* is_null */ NULL, /* check_null */ false, /* arg_num */ 1)) {
php_error_docref(NULL, E_WARNING, "Argument #1 ($file_descriptor) must be of type int|resource, %s given",
zend_zval_value_name(z_fd));
fd = zval_get_long(z_fd);
RETURN_FALSE;
}
/* fd must fit in an int and be positive */
if (fd < 0 || fd > INT_MAX) {
Expand Down
24 changes: 24 additions & 0 deletions ext/posix/tests/posix_ttyname_invalid_type_no_fallback.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
posix_ttyname(): invalid argument type does not fall back to file descriptor 0
--EXTENSIONS--
posix
--FILE--
<?php

var_dump(posix_ttyname("abc"));
var_dump(posix_ttyname([]));
var_dump(posix_ttyname(new stdClass));
var_dump(posix_isatty("abc"));
?>
--EXPECTF--
Warning: posix_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, string given in %s on line %d
bool(false)

Warning: posix_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, array given in %s on line %d
bool(false)

Warning: posix_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, stdClass given in %s on line %d
bool(false)

Warning: posix_isatty(): Argument #1 ($file_descriptor) must be of type int|resource, string given in %s on line %d
bool(false)
2 changes: 0 additions & 2 deletions ext/posix/tests/posix_ttyname_manual_zpp.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ bool(false)
class:
Warning: posix_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, stdClass given in %s on line %d

Warning: Object of class stdClass could not be converted to int in %s on line %d
bool(false)
stringable class:
Warning: posix_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, classWithToString given in %s on line %d

Warning: Object of class classWithToString could not be converted to int in %s on line %d
bool(false)
int castable class:
Warning: posix_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, GMP given in %s on line %d
Expand Down
Loading