Skip to content

Commit eef11e0

Browse files
committed
Fix phpGH-19798: XP_SOCKET XP_SSL: Incorrect condition for Win
This fixes incorrect type conversion and subsequent check for Windows where returned socket is not an int. It should be noted that this is not really an issue as previous int would get negative so the check should still work. The issue actually happens only in master (PHP 8.5) where refactoring has been done and the type changed. Closes phpGH-19881
1 parent 48e3608 commit eef11e0

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ PHP NEWS
7070
- Standard:
7171
. Fix shm corruption with coercion in options of unserialize(). (nielsdos)
7272

73+
- Streams:
74+
. Fixed bug GH-19798: XP_SOCKET XP_SSL (Socket stream modules): Incorrect
75+
condition for Win32/Win64. (Jakub Zelenka)
76+
77+
7378
- Tidy:
7479
. Fixed GH-19021 (improved tidyOptGetCategory detection).
7580
(arjendekorte, David Carlier, Peter Kokot)

ext/openssl/xp_ssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,7 +2342,7 @@ static int php_openssl_sockop_stat(php_stream *stream, php_stream_statbuf *ssb)
23422342
static inline int php_openssl_tcp_sockop_accept(php_stream *stream, php_openssl_netstream_data_t *sock,
23432343
php_stream_xport_param *xparam STREAMS_DC) /* {{{ */
23442344
{
2345-
int clisock;
2345+
php_socket_t clisock;
23462346
bool nodelay = 0;
23472347
zval *tmpzval = NULL;
23482348

@@ -2363,7 +2363,7 @@ static inline int php_openssl_tcp_sockop_accept(php_stream *stream, php_openssl_
23632363
&xparam->outputs.error_code,
23642364
nodelay);
23652365

2366-
if (clisock >= 0) {
2366+
if (clisock != SOCK_ERR) {
23672367
php_openssl_netstream_data_t *clisockdata = (php_openssl_netstream_data_t*) emalloc(sizeof(*clisockdata));
23682368

23692369
/* copy underlying tcp fields */

main/streams/xp_socket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_
854854
static inline int php_tcp_sockop_accept(php_stream *stream, php_netstream_data_t *sock,
855855
php_stream_xport_param *xparam STREAMS_DC)
856856
{
857-
int clisock;
857+
php_socket_t clisock;
858858
bool nodelay = 0;
859859
zval *tmpzval = NULL;
860860

@@ -875,7 +875,7 @@ static inline int php_tcp_sockop_accept(php_stream *stream, php_netstream_data_t
875875
&xparam->outputs.error_code,
876876
nodelay);
877877

878-
if (clisock >= 0) {
878+
if (clisock != SOCK_ERR) {
879879
php_netstream_data_t *clisockdata = (php_netstream_data_t*) emalloc(sizeof(*clisockdata));
880880

881881
memcpy(clisockdata, sock, sizeof(*clisockdata));

0 commit comments

Comments
 (0)