]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
snmp: remove extra '\n' at the end of SNMP log message
authorVincent Bernat <bernat@luffy.cx>
Wed, 20 Jun 2012 16:45:19 +0000 (18:45 +0200)
committerVincent Bernat <bernat@luffy.cx>
Wed, 20 Jun 2012 16:45:19 +0000 (18:45 +0200)
Putting `\0` is useless. The code was done to remove an extra `\n`.

src/agent.c

index c76af5a3f30d42a0b963deeb4da2f1dd0d27e5ae..ed325f57d5e2187ddfa8968867d669a6dd6c55a5 100644 (file)
@@ -1673,7 +1673,8 @@ agent_log_callback(int major, int minor,
   struct snmp_log_message *slm = (struct snmp_log_message *)serverarg;
   char *msg = strdup(slm->msg);
   (void)major; (void)minor; (void)clientarg;
-  if (msg) msg[strlen(msg)-1] = '\0';
+
+  if (msg && msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = '\0';
   switch (slm->priority) {
   case LOG_EMERG:   log_warnx("snmp[emerg]: %s",   msg?msg:slm->msg); break;
   case LOG_ALERT:   log_warnx("snmp[alert]: %s",   msg?msg:slm->msg); break;