All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] printk: Don't read beyond string arguments' terminating zero
@ 2008-04-09 16:41 Markus Armbruster
  0 siblings, 0 replies; only message in thread
From: Markus Armbruster @ 2008-04-09 16:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Adrian Bunk

Fix add_preferred_console() and update_console_cmdline() not to to
read beyond the terminating zero of their name argument.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 kernel/printk.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index c46a20a..52526df 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -865,7 +865,7 @@ int add_preferred_console(char *name, int idx, char *options)
 		return -E2BIG;
 	selected_console = i;
 	c = &console_cmdline[i];
-	memcpy(c->name, name, sizeof(c->name));
+	strlcpy(c->name, name, sizeof(c->name));
 	c->name[sizeof(c->name) - 1] = 0;
 	c->options = options;
 	c->index = idx;
@@ -881,7 +881,7 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha
 		if (strcmp(console_cmdline[i].name, name) == 0 &&
 			  console_cmdline[i].index == idx) {
 				c = &console_cmdline[i];
-				memcpy(c->name, name_new, sizeof(c->name));
+				strlcpy(c->name, name_new, sizeof(c->name));
 				c->name[sizeof(c->name) - 1] = 0;
 				c->options = options;
 				c->index = idx_new;
-- 
1.5.3.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-09 16:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-09 16:41 [PATCH] printk: Don't read beyond string arguments' terminating zero Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.