]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
eve: check redis reply in non pipeline mode
authorfooinha <fooinha@gmail.com>
Mon, 24 Oct 2016 15:52:06 +0000 (15:52 +0000)
committerVictor Julien <victor@inliniac.net>
Thu, 27 Oct 2016 07:19:18 +0000 (09:19 +0200)
We may lose the reply if disconnection happens.
Reconnection is needed.

src/util-logopenfile.c

index 120742a1f996d2f9eeb72baa081ce00422905478..f35a7acdbb774cfb22fd776649bede4c11d80eee 100644 (file)
@@ -597,21 +597,26 @@ static int  LogFileWriteRedis(LogFileCtx *file_ctx, const char *string, size_t s
                 file_ctx->redis_setup.key,
                 string);
 
-        switch (reply->type) {
-            case REDIS_REPLY_ERROR:
-                SCLogWarning(SC_ERR_SOCKET, "Redis error: %s", reply->str);
-                SCConfLogReopenRedis(file_ctx);
-                break;
-            case REDIS_REPLY_INTEGER:
-                SCLogDebug("Redis integer %lld", reply->integer);
-                break;
-            default:
-                SCLogError(SC_ERR_INVALID_VALUE,
-                        "Redis default triggered with %d", reply->type);
-                SCConfLogReopenRedis(file_ctx);
-                break;
+        /*  We may lose the reply if disconnection happens! */
+        if (reply) {
+            switch (reply->type) {
+                case REDIS_REPLY_ERROR:
+                    SCLogWarning(SC_ERR_SOCKET, "Redis error: %s", reply->str);
+                    SCConfLogReopenRedis(file_ctx);
+                    break;
+                case REDIS_REPLY_INTEGER:
+                    SCLogDebug("Redis integer %lld", reply->integer);
+                    break;
+                default:
+                    SCLogError(SC_ERR_INVALID_VALUE,
+                            "Redis default triggered with %d", reply->type);
+                    SCConfLogReopenRedis(file_ctx);
+                    break;
+            }
+            freeReplyObject(reply);
+        } else {
+            SCConfLogReopenRedis(file_ctx);
         }
-        freeReplyObject(reply);
     }
     return 0;
 }