]> granicus.if.org Git - sudo/commitdiff
Fix removal of trailing newlines in a debug message.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 6 Oct 2013 20:22:14 +0000 (14:22 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 6 Oct 2013 20:22:14 +0000 (14:22 -0600)
common/sudo_debug.c

index 7652cf6fe231db6cb11627f00d2b33ad9a02db50..3f142ef02424fdbdbbd001935d8a2d2f98ae81a9 100644 (file)
@@ -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++;
     }