lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1254904787-11323-2-git-send-email-alan-jenkins@tuffmail.co.uk>
Date:	Wed,  7 Oct 2009 09:39:41 +0100
From:	Alan Jenkins <alan-jenkins@...fmail.co.uk>
To:	mingo@...hat.com
Cc:	x86@...nel.org, linux-kernel@...r.kernel.org,
	torvalds@...ux-foundation.org,
	Alan Jenkins <alan-jenkins@...fmail.co.uk>
Subject: [PATCH 1/7] printk: clean up return value

Commit 5fd29d6 "printk: clean up handling of log-levels and newlines"
causes printk() to return the wrong number of characters.

It counts the first loglevel tag twice: once in the original message
string, and a second time when we actually print the loglevel.

We could fix this up, but it seems pointless.  Callers don't really care
about the extra characters added by printk().  Instead, let's return the
length of the original message as formatted (and possibly truncated)
by vscnprintf().

Signed-off-by: Alan Jenkins <alan-jenkins@...fmail.co.uk>
---
 kernel/printk.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index f38b07f..9d3d594 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -669,7 +669,7 @@ static inline void printk_delay(void)
 
 asmlinkage int vprintk(const char *fmt, va_list args)
 {
-	int printed_len = 0;
+	int message_len = 0;
 	int current_log_level = default_message_loglevel;
 	unsigned long flags;
 	int this_cpu;
@@ -708,11 +708,11 @@ asmlinkage int vprintk(const char *fmt, va_list args)
 	if (recursion_bug) {
 		recursion_bug = 0;
 		strcpy(printk_buf, recursion_bug_msg);
-		printed_len = strlen(recursion_bug_msg);
+		message_len = strlen(recursion_bug_msg);
 	}
 	/* Emit the output into the temporary buffer */
-	printed_len += vscnprintf(printk_buf + printed_len,
-				  sizeof(printk_buf) - printed_len, fmt, args);
+	message_len = vscnprintf(printk_buf + message_len,
+				  sizeof(printk_buf) - message_len, fmt, args);
 
 
 	p = printk_buf;
@@ -796,7 +796,7 @@ out_restore_irqs:
 	raw_local_irq_restore(flags);
 
 	preempt_enable();
-	return printed_len;
+	return message_len;
 }
 EXPORT_SYMBOL(printk);
 EXPORT_SYMBOL(vprintk);
-- 
1.6.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ