From 07b08649a86aaee759ba140c5b268d16f2f18e74 Mon Sep 17 00:00:00 2001 From: mrazavi64 Date: Sat, 29 Apr 2017 15:50:40 +0430 Subject: [PATCH] Fix UnixSyslog message ident corruption (#20) According to openlog(3) documentation: if the string *ident points to ceases to exist, the results are undefined". So we have to keep the identBuffer during the existence of the Syslog object. Closes #21 --- src/main/java/org/graylog2/syslog4j/impl/unix/UnixSyslog.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/graylog2/syslog4j/impl/unix/UnixSyslog.java b/src/main/java/org/graylog2/syslog4j/impl/unix/UnixSyslog.java index 1bc66a1..9d97596 100644 --- a/src/main/java/org/graylog2/syslog4j/impl/unix/UnixSyslog.java +++ b/src/main/java/org/graylog2/syslog4j/impl/unix/UnixSyslog.java @@ -37,6 +37,8 @@ public class UnixSyslog extends AbstractSyslog { public void closelog(); } + protected static Memory identBuffer = null; + protected static int currentFacility = -1; protected static boolean openlogCalled = false; @@ -81,8 +83,6 @@ public class UnixSyslog extends AbstractSyslog { ident = null; } - Memory identBuffer = null; - if (ident != null) { identBuffer = new Memory(128); identBuffer.setString(0, ident, false);