diff options
author | Owen Smith <owen.rl.smith@gmail.com> | 2019-07-17 22:04:05 +0300 |
---|---|---|
committer | Pavlo Yatsukhnenko <yatsukhnenko@gmail.com> | 2019-07-29 18:04:02 +0300 |
commit | 135a62de6e0f59f7a9f4af653ce02832a2cfae7d (patch) | |
tree | 93dd6e27288b870b6db81485d2d8a38833ba1823 | |
parent | 6a5c17a0b81f9604223dbe1894732808a88f91e6 (diff) |
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
-rw-r--r-- | common.h | 2 | ||||
-rw-r--r-- | redis.c | 4 |
2 files changed, 5 insertions, 1 deletions
@@ -246,7 +246,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; @@ -978,6 +978,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) { |