Fix "No such file or directory" when connecting to ports >= 32768 (#1602)

* Fix `connect` for port numbers >=32768:

Since 5.0.0, using a high enough port number gives a "No such file or directory" error, because type casts treat high ports as -ve which awkwardly triggers the unix-socket-path behaviour.

* clean up guard condition
This commit is contained in:
Owen Smith
2019-07-17 20:04:05 +01:00
committed by Michael Grunder
parent 4ab69b1d16
commit 1f41da64fe
2 changed files with 5 additions and 1 deletions

View File

@@ -248,7 +248,7 @@ typedef struct fold_item {
typedef struct {
php_stream *stream;
zend_string *host;
short port;
unsigned short port;
zend_string *auth;
double timeout;
double read_timeout;

View File

@@ -1005,6 +1005,10 @@ redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
port = 6379;
}
if (port < 0) {
port = 0;
}
redis = PHPREDIS_GET_OBJECT(redis_object, object);
/* if there is a redis sock already we have to remove it */
if (redis->sock) {