Here are to patches for segfaults in imjournal and the ratelimiter.
Rationales are in the commit messages.
Tomas
>From 8928a7501fad1ac822ddadaeb08431feebafe8e7 Mon Sep 17 00:00:00 2001
From: Tomas Heinrich <[email protected]>
Date: Fri, 7 Jun 2013 01:15:10 +0200
Subject: [PATCH 1/2] bugfix: be more tolerant to malformed journal fields
This prevents a segfault when a malformed journal entry field doesn't
contain an equal sign. Should not ever happen but was actually
triggered by a real bug in systemd journal.
---
plugins/imjournal/imjournal.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c
index ae29154..cce45b9 100755
--- a/plugins/imjournal/imjournal.c
+++ b/plugins/imjournal/imjournal.c
@@ -244,7 +244,14 @@ readjournal() {
SD_JOURNAL_FOREACH_DATA(j, get, l) {
/* locate equal sign, this is always present */
equal_sign = memchr(get, '=', l);
- assert (equal_sign != NULL);
+
+ /* ... but we know better than to trust the specs */
+ if (equal_sign == NULL) {
+ errmsg.LogError(0, RS_RET_ERR,"SD_JOURNAL_FOREACH_DATA()"
+ " returned a malformed field (has no '='): '%s'",
+ get);
+ continue; /* skip the entry */
+ }
/* get length of journal data prefix */
prefixlen = ((char *)equal_sign - (char *)get);
--
1.7.10.4
>From f11a873dc4e258c346765af9d5d23a1180493ee8 Mon Sep 17 00:00:00 2001
From: Tomas Heinrich <[email protected]>
Date: Sat, 8 Jun 2013 23:27:48 +0200
Subject: [PATCH 2/2] bugfix: prevent an endless loop in the ratelimiter
If messages are being dropped because of ratelimiting, an internal
message is generated to inform about this fact. This should happen
only uppon the firs occurance but the counter that tracks the number
of dropped messages was incremented only after sending the message. If
the message itself gets ratelimited, an endless loop spins out of
control. Thanks to Jerry James for notifying about this.
---
runtime/ratelimit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/runtime/ratelimit.c b/runtime/ratelimit.c
index d83da2d..ec24855 100644
--- a/runtime/ratelimit.c
+++ b/runtime/ratelimit.c
@@ -167,13 +167,13 @@ withinRatelimit(ratelimit_t *ratelimit, time_t tt)
ratelimit->done++;
ret = 1;
} else {
- if(ratelimit->missed == 0) {
+ ratelimit->missed++;
+ if(ratelimit->missed == 1) {
snprintf((char*)msgbuf, sizeof(msgbuf),
"%s: begin to drop messages due to rate-limiting",
ratelimit->name);
logmsgInternal(RS_RET_RATE_LIMITED, LOG_SYSLOG|LOG_INFO, msgbuf, 0);
}
- ratelimit->missed++;
ret = 0;
}
--
1.7.10.4
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE
THAT.