Fix for ports >= 1<<15

This commit is contained in:
Bob Weinand 2014-10-20 09:47:35 +02:00
parent 2916a14018
commit fa1c26f022
2 changed files with 6 additions and 5 deletions

View File

@ -150,7 +150,7 @@ PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC)
}
PHPDBG_API int phpdbg_open_socket(const char *interface, short port TSRMLS_DC) {
PHPDBG_API int phpdbg_open_socket(const char *interface, unsigned short port TSRMLS_DC) {
struct addrinfo res;
int fd = phpdbg_create_listenable_socket(interface, port, &res TSRMLS_CC);
@ -169,7 +169,7 @@ PHPDBG_API int phpdbg_open_socket(const char *interface, short port TSRMLS_DC) {
}
PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, int port, struct addrinfo *addr_res TSRMLS_DC) {
PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, unsigned short port, struct addrinfo *addr_res TSRMLS_DC) {
int sock = -1, rc;
int reuse = 1;
struct in6_addr serveraddr;
@ -205,12 +205,13 @@ PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, int port, struc
}
}
snprintf(port_buf, 7, "%d", port);
snprintf(port_buf, 7, "%u", port);
if (!any_addr) {
rc = getaddrinfo(addr, port_buf, &hints, &res);
} else {
rc = getaddrinfo(NULL, port_buf, &hints, &res);
}
if (0 != rc) {
#ifndef PHP_WIN32
if (rc == EAI_SYSTEM) {

View File

@ -26,8 +26,8 @@ PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len);
PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC);
PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC);
PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, int port, struct addrinfo *res TSRMLS_DC);
PHPDBG_API int phpdbg_open_socket(const char *interface, short port TSRMLS_DC);
PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, unsigned short port, struct addrinfo *res TSRMLS_DC);
PHPDBG_API int phpdbg_open_socket(const char *interface, unsigned short port TSRMLS_DC);
PHPDBG_API void phpdbg_close_socket(int sock);
#endif /* PHPDBG_IO_H */