diff options
author | Xinchen Hui <laruence@gmail.com> | 2016-06-18 21:34:33 -0700 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2016-06-18 21:34:33 -0700 |
commit | 3e1329c184d1ba6be49a7a60eb3e3e15f9c913c5 (patch) | |
tree | 4dc0f74f1d691800502cbcbfb3c7fdeac3deb0f7 /main/streams/xp_socket.c | |
parent | a171522983fbc339069689903baadc4e599b523e (diff) | |
parent | af2c332f41c80ff0c138fbd03248be36b545c202 (diff) | |
download | php-git-3e1329c184d1ba6be49a7a60eb3e3e15f9c913c5.tar.gz |
Merge branch 'PHP-7.0'
Diffstat (limited to 'main/streams/xp_socket.c')
-rw-r--r-- | main/streams/xp_socket.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index cc76ace510..8dc8ef8980 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -266,16 +266,26 @@ static inline int sock_recvfrom(php_netstream_data_t *sock, char *buf, size_t bu struct sockaddr **addr, socklen_t *addrlen ) { - php_sockaddr_storage sa; - socklen_t sl = sizeof(sa); int ret; int want_addr = textaddr || addr; if (want_addr) { + php_sockaddr_storage sa; + socklen_t sl = sizeof(sa); ret = recvfrom(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags, (struct sockaddr*)&sa, &sl); ret = (ret == SOCK_CONN_ERR) ? -1 : ret; - php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, sl, - textaddr, addr, addrlen); + if (sl) { + php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, sl, + textaddr, addr, addrlen); + } else { + if (textaddr) { + *textaddr = ZSTR_EMPTY_ALLOC(); + } + if (addr) { + *addr = NULL; + *addrlen = 0; + } + } } else { ret = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags); ret = (ret == SOCK_CONN_ERR) ? -1 : ret; |