Skip to content

Commit da62fd5

Browse files
committed
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.
1 parent d7a45a6 commit da62fd5

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ PHP NEWS
2727
. Fixed bug #64405 (Use freetype-config for determining freetype2 dir(s)).
2828
(Adam)
2929

30+
- MySQLi:
31+
. Fixed bug #65486 (mysqli_poll() is broken on win x64). (Anatol)
32+
3033
- SOAP
3134
. Fixed bug #66112 (Use after free condition in SOAP extension).
3235
(martin dot koegler at brz dot gv dot at)

ext/openssl/xp_ssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ static int php_openssl_sockop_cast(php_stream *stream, int castas, void **ret TS
825825

826826
case PHP_STREAM_AS_FD_FOR_SELECT:
827827
if (ret) {
828-
*(int *)ret = sslsock->s.socket;
828+
*(php_socket_t *)ret = sslsock->s.socket;
829829
}
830830
return SUCCESS;
831831

@@ -835,7 +835,7 @@ static int php_openssl_sockop_cast(php_stream *stream, int castas, void **ret TS
835835
return FAILURE;
836836
}
837837
if (ret) {
838-
*(int *)ret = sslsock->s.socket;
838+
*(php_socket_t *)ret = sslsock->s.socket;
839839
}
840840
return SUCCESS;
841841
default:

main/streams/xp_socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ static int php_sockop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
426426
case PHP_STREAM_AS_FD:
427427
case PHP_STREAM_AS_SOCKETD:
428428
if (ret)
429-
*(int*)ret = sock->socket;
429+
*(php_socket_t *)ret = sock->socket;
430430
return SUCCESS;
431431
default:
432432
return FAILURE;

0 commit comments

Comments
 (0)