From a6b4f41103f62fe2d0f5db5f3d188349fb633202 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sun, 6 Oct 2013 14:22:14 -0600 Subject: [PATCH] Fix removal of trailing newlines in a debug message. --- common/sudo_debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/sudo_debug.c b/common/sudo_debug.c index 7652cf6fe..3f142ef02 100644 --- a/common/sudo_debug.c +++ b/common/sudo_debug.c @@ -339,12 +339,12 @@ sudo_debug_write_file(const char *func, const char *file, int lineno, iov[2].iov_base = sudo_debug_pidstr; iov[2].iov_len = sudo_debug_pidlen; - /* Add string along with newline if it doesn't have one. */ + /* Add string, trimming any trailing newlines. */ + while (len > 0 && str[len - 1] == '\n') + len--; if (len > 0) { iov[iovcnt].iov_base = (char *)str; iov[iovcnt].iov_len = len; - while (len > 0 && str[len - 1] == '\n') - iov[iovcnt].iov_len--; iovcnt++; } -- 2.40.0