22
22
#include <unistd.h>
23
23
#include "ext/standard/info.h"
24
24
#include "php_posix.h"
25
+ #include "main/php_network.h"
25
26
26
27
#ifdef HAVE_POSIX
27
28
@@ -415,7 +416,7 @@ PHP_FUNCTION(posix_ctermid)
415
416
/* }}} */
416
417
417
418
/* Checks if the provides resource is a stream and if it provides a file descriptor */
418
- static zend_result php_posix_stream_get_fd (zval * zfp , zend_long * fd ) /* {{{ */
419
+ static zend_result php_posix_stream_get_fd (zval * zfp , zend_long * ret ) /* {{{ */
419
420
{
420
421
php_stream * stream ;
421
422
@@ -425,19 +426,21 @@ static zend_result php_posix_stream_get_fd(zval *zfp, zend_long *fd) /* {{{ */
425
426
return FAILURE ;
426
427
}
427
428
428
- /* get the fd.
429
+ /* get the fd. php_socket_t is used for FDs, and is shorter than zend_long.
429
430
* NB: Most other code will NOT use the PHP_STREAM_CAST_INTERNAL flag when casting.
430
431
* It is only used here so that the buffered data warning is not displayed.
431
432
*/
433
+ php_socket_t fd = -1 ;
432
434
if (php_stream_can_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL ) == SUCCESS ) {
433
- php_stream_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL , (void * ) fd , 0 );
435
+ php_stream_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL , (void * * ) & fd , 0 );
434
436
} else if (php_stream_can_cast (stream , PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL ) == SUCCESS ) {
435
- php_stream_cast (stream , PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL , (void * ) fd , 0 );
437
+ php_stream_cast (stream , PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL , (void * * ) & fd , 0 );
436
438
} else {
437
439
php_error_docref (NULL , E_WARNING , "Could not use stream of type '%s'" ,
438
440
stream -> ops -> label );
439
441
return FAILURE ;
440
442
}
443
+ * ret = fd ;
441
444
return SUCCESS ;
442
445
}
443
446
/* }}} */
0 commit comments