Blame SOURCES/rsyslog-8.24.0-rhbz1744682-ratelimiter-segfault.patch

552a9e
From b54769b4d8371ce1d60e3c43172a445336ec79b6 Mon Sep 17 00:00:00 2001
552a9e
From: Rainer Gerhards <rgerhards@adiscon.com>
552a9e
Date: Mon, 24 Sep 2018 13:27:26 +0200
552a9e
Subject: [PATCH] bugfix imfile: segfault in ratelimiter
552a9e
552a9e
imfile crashes inside rate limit processing, often when log
552a9e
files are rotated. However, this could occur in any case where
552a9e
the monitored files was closed by imfile, it rotation is just
552a9e
the most probable cause for this (moving the file to another
552a9e
directory or deleting it also can trigger the same issue, for
552a9e
example). The root cause was invalid sequence of operations.
552a9e
552a9e
closes https://github.com/rsyslog/rsyslog/issues/3021
552a9e
---
552a9e
 plugins/imfile/imfile.c | 8 +++---
552a9e
 1 file changed, 3 insertions(+), 3 deletions(-)
552a9e
552a9e
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
552a9e
index e710f7c44c..f4a4ef9b72 100644
552a9e
--- a/plugins/imfile/imfile.c
552a9e
+++ b/plugins/imfile/imfile.c
552a9e
@@ -915,9 +915,6 @@ act_obj_destroy(act_obj_t *const act, const int is_deleted)
552a9e
 			}
552a9e
 		}
552a9e
 	}
552a9e
-	if(act->ratelimiter != NULL) {
552a9e
-		ratelimitDestruct(act->ratelimiter);
552a9e
-	}
552a9e
 	if(act->pStrm != NULL) {
552a9e
 		const instanceConf_t *const inst = act->edge->instarr[0];// TODO: same file, multiple instances?
552a9e
 		pollFile(act); /* get any left-over data */
552a9e
@@ -934,6 +931,9 @@ act_obj_destroy(act_obj_t *const act, const int is_deleted)
552a9e
 			unlink((char*)statefn);
552a9e
 		}
552a9e
 	}
552a9e
+	if(act->ratelimiter != NULL) {
552a9e
+		ratelimitDestruct(act->ratelimiter);
552a9e
+	}
552a9e
 	#ifdef HAVE_INOTIFY_INIT
552a9e
 	if(act->wd != -1) {
552a9e
 		wdmapDel(act->wd);