Skip to content

Commit 8657f03

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78210: Invalid pointer address
2 parents a72b261 + 53797c2 commit 8657f03

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ PHP NEWS
55

66
- Core:
77
. Fixed bug #79364 (When copy empty array, next key is unspecified). (cmb)
8+
. Fixed bug #78210 (Invalid pointer address). (cmb, Nikita)
89

910
- SOAP:
1011
. Fixed bug #79357 (SOAP request segfaults when any request parameter is

ext/standard/streamsfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ PHP_FUNCTION(stream_socket_sendto)
354354
}
355355
}
356356

357-
RETURN_LONG(php_stream_xport_sendto(stream, data, datalen, (int)flags, target_addr ? &sa : NULL, sl));
357+
RETURN_LONG(php_stream_xport_sendto(stream, data, datalen, (int)flags, target_addr_len ? &sa : NULL, sl));
358358
}
359359
/* }}} */
360360

main/network.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,11 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo
513513
zend_string *errstr = NULL;
514514
#if HAVE_IPV6
515515
struct sockaddr_in6 *in6 = (struct sockaddr_in6*)sa;
516-
#endif
517516

518-
memset(sa, 0, sizeof(struct sockaddr));
517+
memset(in6, 0, sizeof(struct sockaddr_in6));
518+
#else
519+
memset(in4, 0, sizeof(struct sockaddr_in));
520+
#endif
519521

520522
if (*addr == '[') {
521523
colon = memchr(addr + 1, ']', addrlen-1);

main/streams/xp_socket.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ static inline int sock_recvfrom(php_netstream_data_t *sock, char *buf, size_t bu
278278
socklen_t sl = sizeof(sa);
279279
ret = recvfrom(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags, (struct sockaddr*)&sa, &sl);
280280
ret = (ret == SOCK_CONN_ERR) ? -1 : ret;
281+
#ifdef PHP_WIN32
282+
/* POSIX discards excess bytes without signalling failure; emulate this on Windows */
283+
if (ret == -1 && WSAGetLastError() == WSAEMSGSIZE) {
284+
ret = buflen;
285+
}
286+
#endif
281287
if (sl) {
282288
php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, sl,
283289
textaddr, addr, addrlen);

0 commit comments

Comments
 (0)