about summary refs log tree commit diff
path: root/misc/syslog.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc/syslog.c')
-rw-r--r--misc/syslog.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/misc/syslog.c b/misc/syslog.c
index ee832fefbe..9690bf1da6 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -177,10 +177,14 @@ vsyslog(pri, fmt, ap)
 
 		v->iov_base = buf + msgoff;
 		v->iov_len = bufsize - msgoff;
-		++v;
-		v->iov_base = (char *) "\n";
-		v->iov_len = 1;
-		(void)__writev(STDERR_FILENO, iov, 2);
+		/* Append a newline if necessary.  */
+		if (buf[bufsize - 1] != '\n')
+		  {
+		    ++v;
+		    v->iov_base = (char *) "\n";
+		    v->iov_len = 1;
+		  }
+		(void)__writev(STDERR_FILENO, iov, v - iov + 1);
 	}
 
 	/* Prepare for multiple users.  We have to take care: open and