Skip to content

Commit

Permalink
Squashed 'deps/hiredis/' changes from b6a052fe0..60e5075d4
Browse files Browse the repository at this point in the history
60e5075d4 Version 1.2.0 (redis#1202)
adef139a7 Remove support in deprecated TLS versions 1.0 and 1.1 (redis#1205)
d543baba6 Install major version symlink of shared objects.
052f99ab2 Ensure functionality without _MSC_VER definition
ded32c7d1 Add a test for the TCP_USER_TIMEOUT option. (redis#1192)
5cbd1f296 Add -Werror as a default. (redis#1193)
af1445638 CI: Update homebrew Redis version. (redis#1191)
6de326e87 Fix a typo in b6a052f.

git-subtree-dir: deps/hiredis
git-subtree-split: 60e5075d4ac77424809f855ba3e398df7aacefe8
  • Loading branch information
chayim committed Jul 13, 2023
1 parent fad6c71 commit 67ed318
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ jobs:

- name: Install dependencies
run: |
brew install openssl redis@6.2
brew link redis@6.2 --force
brew install openssl redis@7.0
brew link redis@7.0 --force
- name: Build hiredis
run: USE_SSL=1 make
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
steps:
- name: Install qemu
if: matrix.emulator
run: sudo apt-get install -y qemu-user
run: sudo apt-get update && sudo apt-get install -y qemu-user
- name: Install platform toolset
if: matrix.toolset
run: sudo apt-get install -y gcc-${{matrix.toolset}}
Expand Down
57 changes: 54 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,71 @@
## [1.2.0](https://github.com/redis/hiredis/tree/v1.2.0) - (2023-06-04)

Announcing Hiredis v1.2.0 with with new adapters, and a great many bug fixes.

## 🚀 New Features

- Add sdevent adapter @Oipo (#1144)
- Allow specifying the keepalive interval @michael-grunder (#1168)
- Add RedisModule adapter @tezc (#1182)
- Helper for setting TCP_USER_TIMEOUT socket option @zuiderkwast (#1188)

## 🐛 Bug Fixes

- Fix a typo in b6a052f. @yossigo (#1190)
- Fix wincrypt symbols conflict @hudayou (#1151)
- Don't attempt to set a timeout if we are in an error state. @michael-grunder (#1180)
- Accept -nan per the RESP3 spec recommendation. @michael-grunder (#1178)
- Fix colliding option values @zuiderkwast (#1172)
- Ensure functionality without `_MSC_VER` definition @windyakin (#1194)

## 🧰 Maintenance

- Add a test for the TCP_USER_TIMEOUT option. @michael-grunder (#1192)
- Add -Werror as a default. @yossigo (#1193)
- CI: Update homebrew Redis version. @yossigo (#1191)
- Fix typo in makefile. @michael-grunder (#1179)
- Write a version file for the CMake package @Neverlord (#1165)
- CMakeLists.txt: respect BUILD_SHARED_LIBS @ffontaine (#1147)
- Cmake static or shared @autoantwort (#1160)
- fix typo @tillkruss (#1153)
- Add a test ensuring we don't clobber connection error. @michael-grunder (#1181)
- Search for openssl on macOS @michael-grunder (#1169)


## Contributors
We'd like to thank all the contributors who worked on this release!

<a href="https://github.com/neverlord"><img src="https://github.com/neverlord.png" width="32" height="32"></a>
<a href="https://github.com/Oipo"><img src="https://github.com/Oipo.png" width="32" height="32"></a>
<a href="https://github.com/autoantwort"><img src="https://github.com/autoantwort.png" width="32" height="32"></a>
<a href="https://github.com/ffontaine"><img src="https://github.com/ffontaine.png" width="32" height="32"></a>
<a href="https://github.com/hudayou"><img src="https://github.com/hudayou.png" width="32" height="32"></a>
<a href="https://github.com/michael-grunder"><img src="https://github.com/michael-grunder.png" width="32" height="32"></a>
<a href="https://github.com/postgraph"><img src="https://github.com/postgraph.png" width="32" height="32"></a>
<a href="https://github.com/tezc"><img src="https://github.com/tezc.png" width="32" height="32"></a>
<a href="https://github.com/tillkruss"><img src="https://github.com/tillkruss.png" width="32" height="32"></a>
<a href="https://github.com/vityafx"><img src="https://github.com/vityafx.png" width="32" height="32"></a>
<a href="https://github.com/windyakin"><img src="https://github.com/windyakin.png" width="32" height="32"></a>
<a href="https://github.com/yossigo"><img src="https://github.com/yossigo.png" width="32" height="32"></a>
<a href="https://github.com/zuiderkwast"><img src="https://github.com/zuiderkwast.png" width="32" height="32"></a>

## [1.1.0](https://github.com/redis/hiredis/tree/v1.1.0) - (2022-11-15)

Announcing Hiredis v1.1.0 GA with better SSL convenience, new async adapters and a great many bug fixes.

**NOTE**: Hiredis can now return `nan` in addition to `-inf` and `inf` when returning a `REDIS_REPLY_DOUBLE`.
**NOTE**: Hiredis can now return `nan` in addition to `-inf` and `inf` when returning a `REDIS_REPLY_DOUBLE`.

## 🐛 Bug Fixes

- Add support for nan in RESP3 double [@filipecosta90](https://github.com/filipecosta90)
- Add support for nan in RESP3 double [@filipecosta90](https://github.com/filipecosta90)
([\#1133](https://github.com/redis/hiredis/pull/1133))

## 🧰 Maintenance

- Add an example that calls redisCommandArgv [@michael-grunder](https://github.com/michael-grunder)
([\#1140](https://github.com/redis/hiredis/pull/1140))
- fix flag reference [@pata00](https://github.com/pata00) ([\#1136](https://github.com/redis/hiredis/pull/1136))
- Make freeing a NULL redisAsyncContext a no op. [@michael-grunder](https://github.com/michael-grunder)
- Make freeing a NULL redisAsyncContext a no op. [@michael-grunder](https://github.com/michael-grunder)
([\#1135](https://github.com/redis/hiredis/pull/1135))
- CI updates ([@bjosv](https://github.com/redis/bjosv) ([\#1139](https://github.com/redis/hiredis/pull/1139))

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export REDIS_TEST_CONFIG
CC:=$(shell sh -c 'type $${CC%% *} >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
CXX:=$(shell sh -c 'type $${CXX%% *} >/dev/null 2>/dev/null && echo $(CXX) || echo g++')
OPTIMIZATION?=-O3
WARNINGS=-Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers
WARNINGS=-Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers
DEBUG_FLAGS?= -g -ggdb
REAL_CFLAGS=$(OPTIMIZATION) -fPIC $(CPPFLAGS) $(CFLAGS) $(WARNINGS) $(DEBUG_FLAGS) $(PLATFORM_FLAGS)
REAL_LDFLAGS=$(LDFLAGS)
Expand Down Expand Up @@ -311,7 +311,7 @@ install: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME) $(SSL_INSTALL)
$(INSTALL) hiredis.h async.h read.h sds.h alloc.h sockcompat.h $(INSTALL_INCLUDE_PATH)
$(INSTALL) adapters/*.h $(INSTALL_INCLUDE_PATH)/adapters
$(INSTALL) $(DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(DYLIB_MINOR_NAME)
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(DYLIB_MINOR_NAME) $(DYLIBNAME)
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(DYLIB_MINOR_NAME) $(DYLIBNAME) && ln -sf $(DYLIB_MINOR_NAME) $(DYLIB_MAJOR_NAME)
$(INSTALL) $(STLIBNAME) $(INSTALL_LIBRARY_PATH)
mkdir -p $(INSTALL_PKGCONF_PATH)
$(INSTALL) $(PKGCONFNAME) $(INSTALL_PKGCONF_PATH)
Expand All @@ -320,7 +320,7 @@ install-ssl: $(SSL_DYLIBNAME) $(SSL_STLIBNAME) $(SSL_PKGCONFNAME)
mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_LIBRARY_PATH)
$(INSTALL) hiredis_ssl.h $(INSTALL_INCLUDE_PATH)
$(INSTALL) $(SSL_DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(SSL_DYLIB_MINOR_NAME)
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(SSL_DYLIB_MINOR_NAME) $(SSL_DYLIBNAME)
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(SSL_DYLIB_MINOR_NAME) $(SSL_DYLIBNAME) && ln -sf $(SSL_DYLIB_MINOR_NAME) $(SSL_DYLIB_MAJOR_NAME)
$(INSTALL) $(SSL_STLIBNAME) $(INSTALL_LIBRARY_PATH)
mkdir -p $(INSTALL_PKGCONF_PATH)
$(INSTALL) $(SSL_PKGCONFNAME) $(INSTALL_PKGCONF_PATH)
Expand Down
4 changes: 2 additions & 2 deletions hiredis.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,12 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) {
while (*_p != '\0' && strchr(flags,*_p) != NULL) _p++;

/* Field width */
while (*_p != '\0' && isdigit(*_p)) _p++;
while (*_p != '\0' && isdigit((int) *_p)) _p++;

/* Precision */
if (*_p == '.') {
_p++;
while (*_p != '\0' && isdigit(*_p)) _p++;
while (*_p != '\0' && isdigit((int) *_p)) _p++;
}

/* Copy va_list before consuming with va_arg */
Expand Down
6 changes: 3 additions & 3 deletions hiredis.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ typedef long long ssize_t;
#include "alloc.h" /* for allocation wrappers */

#define HIREDIS_MAJOR 1
#define HIREDIS_MINOR 1
#define HIREDIS_PATCH 1
#define HIREDIS_SONAME 1.1.1-dev
#define HIREDIS_MINOR 2
#define HIREDIS_PATCH 0
#define HIREDIS_SONAME 1.1.0

/* Connection type can be blocking or non-blocking and is set in the
* least significant bit of the flags field in redisContext. */
Expand Down
3 changes: 2 additions & 1 deletion net.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,10 @@ int redisContextSetTcpUserTimeout(redisContext *c, unsigned int timeout) {
res = setsockopt(c->fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout, sizeof(timeout));
#else
res = -1;
errno = ENOTSUP;
(void)timeout;
#endif
if (res == -1); {
if (res == -1) {
__redisSetErrorFromErrno(c,REDIS_ERR_IO,"setsockopt(TCP_USER_TIMEOUT)");
redisNetClose(c);
return REDIS_ERR;
Expand Down
12 changes: 6 additions & 6 deletions sds.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ sds sdscatrepr(sds s, const char *p, size_t len) {
case '\a': s = sdscatlen(s,"\\a",2); break;
case '\b': s = sdscatlen(s,"\\b",2); break;
default:
if (isprint(*p))
if (isprint((int) *p))
s = sdscatprintf(s,"%c",*p);
else
s = sdscatprintf(s,"\\x%02x",(unsigned char)*p);
Expand Down Expand Up @@ -948,7 +948,7 @@ sds *sdssplitargs(const char *line, int *argc) {
*argc = 0;
while(1) {
/* skip blanks */
while(*p && isspace(*p)) p++;
while(*p && isspace((int) *p)) p++;
if (*p) {
/* get a token */
int inq=0; /* set to 1 if we are in "quotes" */
Expand All @@ -959,8 +959,8 @@ sds *sdssplitargs(const char *line, int *argc) {
while(!done) {
if (inq) {
if (*p == '\\' && *(p+1) == 'x' &&
isxdigit(*(p+2)) &&
isxdigit(*(p+3)))
isxdigit((int) *(p+2)) &&
isxdigit((int) *(p+3)))
{
unsigned char byte;

Expand All @@ -984,7 +984,7 @@ sds *sdssplitargs(const char *line, int *argc) {
} else if (*p == '"') {
/* closing quote must be followed by a space or
* nothing at all. */
if (*(p+1) && !isspace(*(p+1))) goto err;
if (*(p+1) && !isspace((int) *(p+1))) goto err;
done=1;
} else if (!*p) {
/* unterminated quotes */
Expand All @@ -999,7 +999,7 @@ sds *sdssplitargs(const char *line, int *argc) {
} else if (*p == '\'') {
/* closing quote must be followed by a space or
* nothing at all. */
if (*(p+1) && !isspace(*(p+1))) goto err;
if (*(p+1) && !isspace((int) *(p+1))) goto err;
done=1;
} else if (!*p) {
/* unterminated quotes */
Expand Down
20 changes: 17 additions & 3 deletions ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
#include "async_private.h"
#include "hiredis_ssl.h"

#define OPENSSL_1_1_0 0x10100000L

void __redisSetError(redisContext *c, int type, const char *str);

struct redisSSLContext {
Expand Down Expand Up @@ -100,7 +102,7 @@ redisContextFuncs redisContextSSLFuncs;
* Note that this is only required for OpenSSL < 1.1.0.
*/

#if OPENSSL_VERSION_NUMBER < 0x10100000L
#if OPENSSL_VERSION_NUMBER < OPENSSL_1_1_0
#define HIREDIS_USE_CRYPTO_LOCKS
#endif

Expand Down Expand Up @@ -256,13 +258,25 @@ redisSSLContext *redisCreateSSLContextWithOptions(redisSSLOptions *options, redi
if (ctx == NULL)
goto error;

ctx->ssl_ctx = SSL_CTX_new(SSLv23_client_method());
const SSL_METHOD *ssl_method;
#if OPENSSL_VERSION_NUMBER >= OPENSSL_1_1_0
ssl_method = TLS_client_method();
#else
ssl_method = SSLv23_client_method();
#endif

ctx->ssl_ctx = SSL_CTX_new(ssl_method);
if (!ctx->ssl_ctx) {
if (error) *error = REDIS_SSL_CTX_CREATE_FAILED;
goto error;
}

SSL_CTX_set_options(ctx->ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
#if OPENSSL_VERSION_NUMBER >= OPENSSL_1_1_0
SSL_CTX_set_min_proto_version(ctx->ssl_ctx, TLS1_2_VERSION);
#else
SSL_CTX_set_options(ctx->ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1);
#endif

SSL_CTX_set_verify(ctx->ssl_ctx, options->verify_mode, NULL);

if ((cert_filename != NULL && private_key_filename == NULL) ||
Expand Down
16 changes: 14 additions & 2 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int tests = 0, fails = 0, skips = 0;

static void millisleep(int ms)
{
#if _MSC_VER
#ifdef _MSC_VER
Sleep(ms);
#else
usleep(ms*1000);
Expand Down Expand Up @@ -409,10 +409,19 @@ static void test_tcp_options(struct config cfg) {
redisContext *c;

c = do_connect(cfg);

test("We can enable TCP_KEEPALIVE: ");
test_cond(redisEnableKeepAlive(c) == REDIS_OK);

disconnect(c, 0);
#ifdef TCP_USER_TIMEOUT
test("We can set TCP_USER_TIMEOUT: ");
test_cond(redisSetTcpUserTimeout(c, 100) == REDIS_OK);
#else
test("Setting TCP_USER_TIMEOUT errors when unsupported: ");
test_cond(redisSetTcpUserTimeout(c, 100) == REDIS_ERR && c->err == REDIS_ERR_IO);
#endif

redisFree(c);
}

static void test_reply_reader(void) {
Expand Down Expand Up @@ -1567,6 +1576,9 @@ static void test_throughput(struct config config) {
// }

#ifdef HIREDIS_TEST_ASYNC

#pragma GCC diagnostic ignored "-Woverlength-strings" /* required on gcc 4.8.x due to assert statements */

struct event_base *base;

typedef struct TestState {
Expand Down

0 comments on commit 67ed318

Please sign in to comment.