summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Grunder <michael.grunder@gmail.com>2022-08-29 11:29:04 -0700
committerGitHub <noreply@github.com>2022-08-29 11:29:04 -0700
commitdf8b74d69e827d715ddf2281f0c0bcbd320b6816 (patch)
treeb6ffb5cb7afc8d6e2ca09342eaa7cfab8ed2ba75
parent507a6dcaa5471ea395964e3166d402799f3db2fe (diff)
parent0ed6cdec35aa8bb781bd1859c3b4e6b7ec61de10 (diff)
Merge pull request #1091 from redis/ssl-error-ub-fix
Fix some undefined behavior
-rw-r--r--examples/example-libevent-ssl.c2
-rw-r--r--examples/example-ssl.c7
2 files changed, 4 insertions, 5 deletions
diff --git a/examples/example-libevent-ssl.c b/examples/example-libevent-ssl.c
index 7d99af1..d0998ba 100644
--- a/examples/example-libevent-ssl.c
+++ b/examples/example-libevent-ssl.c
@@ -56,7 +56,7 @@ int main (int argc, char **argv) {
const char *caCert = argc > 5 ? argv[6] : NULL;
redisSSLContext *ssl;
- redisSSLContextError ssl_error;
+ redisSSLContextError ssl_error = REDIS_SSL_CTX_NONE;
redisInitOpenSSL();
diff --git a/examples/example-ssl.c b/examples/example-ssl.c
index b8ca442..6d1e32e 100644
--- a/examples/example-ssl.c
+++ b/examples/example-ssl.c
@@ -12,7 +12,7 @@
int main(int argc, char **argv) {
unsigned int j;
redisSSLContext *ssl;
- redisSSLContextError ssl_error;
+ redisSSLContextError ssl_error = REDIS_SSL_CTX_NONE;
redisContext *c;
redisReply *reply;
if (argc < 4) {
@@ -27,9 +27,8 @@ int main(int argc, char **argv) {
redisInitOpenSSL();
ssl = redisCreateSSLContext(ca, NULL, cert, key, NULL, &ssl_error);
- if (!ssl) {
- printf("SSL Context error: %s\n",
- redisSSLContextGetError(ssl_error));
+ if (!ssl || ssl_error != REDIS_SSL_CTX_NONE) {
+ printf("SSL Context error: %s\n", redisSSLContextGetError(ssl_error));
exit(1);
}