Skip to content

Commit a44239c

Browse files
committed
Fix GH-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 GH-19881
1 parent 6eb3fae commit a44239c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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
@@ -853,7 +853,7 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_
853853
static inline int php_tcp_sockop_accept(php_stream *stream, php_netstream_data_t *sock,
854854
php_stream_xport_param *xparam STREAMS_DC)
855855
{
856-
int clisock;
856+
php_socket_t clisock;
857857
bool nodelay = 0;
858858
zval *tmpzval = NULL;
859859

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

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

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

0 commit comments

Comments
 (0)