All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Adrian Bunk <bunk@kernel.org>
Subject: [PATCH] printk: Don't read beyond string arguments' terminating zero
Date: Wed, 09 Apr 2008 18:41:33 +0200	[thread overview]
Message-ID: <87fxtvx9oi.fsf@pike.pond.sub.org> (raw)

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


                 reply	other threads:[~2008-04-09 16:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fxtvx9oi.fsf@pike.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=bunk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.