summaryrefslogtreecommitdiff
path: root/syslogd/proto.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-08-22 18:20:34 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-08-23 09:07:10 +0200
commit532f5e6819faadb394a0dfa6999ab80044ec7c69 (patch)
tree3befcc2c08565d7f3b92785a467a5ed4fe549aae /syslogd/proto.c
parent73404a09d4f26522902a11b02f27896fa1a23d37 (diff)
Normalize syslog message line endings
Most syslog messages have a line feed at the end, but some don't. This patch removes trailing spaces from all syslog messages that have one and always adds a line feed in the logging back end. Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'syslogd/proto.c')
-rw-r--r--syslogd/proto.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/syslogd/proto.c b/syslogd/proto.c
index 0851ced..4ab2f47 100644
--- a/syslogd/proto.c
+++ b/syslogd/proto.c
@@ -132,6 +132,7 @@ int syslog_msg_parse(syslog_msg_t *msg, char *str)
struct tm tstamp;
pid_t pid = 0;
int priority;
+ size_t len;
memset(msg, 0, sizeof(*msg));
@@ -177,6 +178,11 @@ int syslog_msg_parse(syslog_msg_t *msg, char *str)
msg->ident = ident;
msg->message = str;
+ len = strlen(str);
+ while (len > 0 && isspace(str[len - 1]))
+ --len;
+ str[len] = '\0';
+
if (ident != NULL) {
for (ptr = ident; *ptr != '\0'; ++ptr) {
if (!isalnum(*ptr))