From 03ad9d4ec01c9915dea60787147ecad56d7536c9 Mon Sep 17 00:00:00 2001 From: Mats Klepsland Date: Thu, 22 Dec 2016 08:38:46 +0100 Subject: [PATCH] tls-store: fix bug that causes Suricata to crash Fix bug that causes Suricata to crash when the tls.store keyword is used. *** Error in `/usr/bin/suricata': free(): invalid next size (fast): 0x00007fd4b4373180 *** --- src/log-tlsstore.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/log-tlsstore.c b/src/log-tlsstore.c index 6648f592aa..861a2da69a 100644 --- a/src/log-tlsstore.c +++ b/src/log-tlsstore.c @@ -166,7 +166,6 @@ static void LogTlsLogPem(LogTlsStoreLogThread *aft, const Packet *p, SSLState *s goto end_fwrite_fp; } fclose(fp); - SCFree(aft->enc_buf); //Logging certificate informations memcpy(filename + (strlen(filename) - 3), "meta", 4); @@ -223,7 +222,6 @@ static void LogTlsLogPem(LogTlsStoreLogThread *aft, const Packet *p, SSLState *s end_fwrite_fp: fclose(fp); - SCFree(aft->enc_buf); if (logging_dir_not_writable < LOGGING_WRITE_ISSUE_LIMIT) { SCLogWarning(SC_ERR_FWRITE, "Unable to write certificate"); logging_dir_not_writable++; @@ -338,6 +336,9 @@ static TmEcode LogTlsStoreLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } + if (aft->enc_buf != NULL) + SCFree(aft->enc_buf); + /* clear memory */ memset(aft, 0, sizeof(LogTlsStoreLogThread));