From: Alexander Gozman Date: Fri, 18 Jul 2014 16:36:12 +0000 (+0400) Subject: Fix possible crash when logfile descriptor is invalid X-Git-Tag: suricata-2.1beta1~76 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a0bb4477db15c2820affa003ab80f2e8396ec33c;p=thirdparty%2Fsuricata.git Fix possible crash when logfile descriptor is invalid --- diff --git a/src/util-logopenfile.c b/src/util-logopenfile.c index 86e61db7cc..6d0a25deac 100644 --- a/src/util-logopenfile.c +++ b/src/util-logopenfile.c @@ -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; }