]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Fix possible crash when logfile descriptor is invalid
authorAlexander Gozman <a.gozman@securitycode.ru>
Fri, 18 Jul 2014 16:36:12 +0000 (20:36 +0400)
committerVictor Julien <victor@inliniac.net>
Mon, 28 Jul 2014 06:48:39 +0000 (08:48 +0200)
src/util-logopenfile.c

index 86e61db7ccf1962808b4008ece050c8002963a1c..6d0a25deac97a2a21ce3ec37be725e34ec6f376e 100644 (file)
@@ -81,8 +81,12 @@ static int SCLogFileWrite(const char *buffer, int buffer_len, LogFileCtx *log_ct
         SCConfLogReopen(log_ctx);
     }
 
-    int ret = fwrite(buffer, buffer_len, 1, log_ctx->fp);
-    fflush(log_ctx->fp);
+    int ret = 0;
+
+    if (log_ctx->fp) {
+        ret = fwrite(buffer, buffer_len, 1, log_ctx->fp);
+        fflush(log_ctx->fp);
+    }
 
     return ret;
 }