com php-src: cli: don't cast away const in select() timeout argument: sapi/cli/php_cli_server.c

From: Date: Mon, 09 Dec 2013 15:54:42 +0000
Subject: com php-src: cli: don't cast away const in select() timeout argument: sapi/cli/php_cli_server.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74316@lists.php.net to get a copy of this message
Commit: f33265d57281910652bb58f5f9d8bd9d9dd44fe8 Author: Ard Biesheuvel <ard.biesheuvel@linaro.org> Mon, 9 Dec 2013 16:54:42 +0100 Parents: cfd5ea43017500379ae302a67347641712e921ac Branches: PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f33265d57281910652bb58f5f9d8bd9d9dd44fe8 Log: cli: don't cast away const in select() timeout argument The timeout argument to select() is modified to reflect the time remaining when the function returns on a non-timeout condition. Passing a pointer to const data and casting away the const-ness is asking for trouble, but for some reason, this trouble manifests itself only on non-x86 architectures [whose implementation of select() in glibc is different from the one supplied for x86] Fix this by passing a stack copy of the timeout argument to select() Changed paths: M sapi/cli/php_cli_server.c Diff: diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 105b8ae..939eb5a 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -893,9 +893,11 @@ static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode static int php_cli_server_poller_poll(php_cli_server_poller *poller, const struct timeval *tv) /* {{{ */ { + struct timeval t = *tv; + memmove(&poller->active.rfds, &poller->rfds, sizeof(poller->rfds)); memmove(&poller->active.wfds, &poller->wfds, sizeof(poller->wfds)); - return php_select(poller->max_fd + 1, &poller->active.rfds, &poller->active.wfds, NULL, (struct timeval *)tv); + return php_select(poller->max_fd + 1, &poller->active.rfds, &poller->active.wfds, NULL, &t); } /* }}} */ static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, void *opaque, int(*callback)(void *, int fd, int events)) /* {{{ */

« previous php.cvs (#74316) next »