com php-src: Fixed bug #65486 mysqli_poll() is broken on Win x64: NEWS ext/openssl/xp_ssl.c ma in/streams/xp_socket.c
| From: | Anatol Belski | Date: | Thu, 12 Dec 2013 09:17:01 +0000 |
| Subject: | com php-src: Fixed bug #65486 mysqli_poll() is broken on Win x64: NEWS ext/openssl/xp_ssl.c ma in/streams/xp_socket.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74385@lists.php.net to get a copy of this message | ||
Commit: da62fd5ed824bafc4dc3e90278c3d57d8e74cbe1
Author: Anatol Belski <ab@php.net> Thu, 12 Dec 2013 10:17:01 +0100
Parents: d7a45a67be2b82272a908cff54cc4d78a3c6e206
Branches: PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=da62fd5ed824bafc4dc3e90278c3d57d8e74cbe1
Log:
Fixed bug #65486 mysqli_poll() is broken on Win x64
While this issue is visible in mysqli_poll() functions, the cause
lays deeper in the stream to socket casting API. On Win x64 the
SOCKET datatype is a 64 or 32 bit unsigned, while on Linux/Unix-like
it's 32 bit signed integer. The game of casting 32 bit var to/from
64 bit pointer back and forth is the best way to break it.
Further more, while socket and file descriptors are always integers
on Linux, those are different things using different APIs on Windows.
Even though using integer instead of SOCKET might work on Windows, this
issue might need to be revamped more carefully later. By this time
this patch is tested well with phpt and apps and shows no regressions,
neither in mysqli_poll() nor in any other parts.
Bugs:
https://bugs.php.net/65486
Changed paths:
M NEWS
M ext/openssl/xp_ssl.c
M main/streams/xp_socket.c
Diff:
diff --git a/NEWS b/NEWS
index 40a8515..12132d1 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,9 @@ PHP NEWS
. Fixed bug #64405 (Use freetype-config for determining freetype2 dir(s)).
(Adam)
+- MySQLi:
+ . Fixed bug #65486 (mysqli_poll() is broken on win x64). (Anatol)
+
- SOAP
. Fixed bug #66112 (Use after free condition in SOAP extension).
(martin dot koegler at brz dot gv dot at)
diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c
index a1a7ffc..1d1c91f 100644
--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@ -825,7 +825,7 @@ static int php_openssl_sockop_cast(php_stream *stream, int castas, void **ret TS
case PHP_STREAM_AS_FD_FOR_SELECT:
if (ret) {
- *(int *)ret = sslsock->s.socket;
+ *(php_socket_t *)ret = sslsock->s.socket;
}
return SUCCESS;
@@ -835,7 +835,7 @@ static int php_openssl_sockop_cast(php_stream *stream, int castas, void **ret TS
return FAILURE;
}
if (ret) {
- *(int *)ret = sslsock->s.socket;
+ *(php_socket_t *)ret = sslsock->s..socket;
}
return SUCCESS;
default:
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index a9c050f..34a106e 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -426,7 +426,7 @@ static int php_sockop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
case PHP_STREAM_AS_FD:
case PHP_STREAM_AS_SOCKETD:
if (ret)
- *(int*)ret = sock->socket;
+ *(php_socket_t *)ret = sock->socket;
return SUCCESS;
default:
return FAILURE;