linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel: module: strncpy issue, using strlcpy instead of strncpy
@ 2013-04-07 11:38 Chen Gang
  2013-04-07 14:28 ` Geert Uytterhoeven
  2013-04-08  5:30 ` Rusty Russell
  0 siblings, 2 replies; 15+ messages in thread
From: Chen Gang @ 2013-04-07 11:38 UTC (permalink / raw)
  To: rusty
  Cc: linux-kernel@vger.kernel.org >>
	"linux-kernel@vger.kernel.org"


  ownername and namebuf are all NUL terminated string.

  need always let them ended by '\0'.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 kernel/module.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 3c2c72d..597efd8 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1283,7 +1283,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
 
 getname:
 	/* We must make copy under the lock if we failed to get ref. */
-	strncpy(ownername, module_name(owner), MODULE_NAME_LEN);
+	strlcpy(ownername, module_name(owner), MODULE_NAME_LEN);
 unlock:
 	mutex_unlock(&module_mutex);
 	return sym;
@@ -3464,7 +3464,7 @@ const char *module_address_lookup(unsigned long addr,
 	}
 	/* Make a copy in here where it's safe */
 	if (ret) {
-		strncpy(namebuf, ret, KSYM_NAME_LEN - 1);
+		strlcpy(namebuf, ret, KSYM_NAME_LEN);
 		ret = namebuf;
 	}
 	preempt_enable();
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-04-10 10:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-07 11:38 [PATCH] kernel: module: strncpy issue, using strlcpy instead of strncpy Chen Gang
2013-04-07 14:28 ` Geert Uytterhoeven
2013-04-08  2:48   ` Chen Gang
2013-04-08  3:02     ` Chen Gang
2013-04-08  5:30 ` Rusty Russell
2013-04-08 10:16   ` Chen Gang
2013-04-08 13:45     ` Rusty Russell
2013-04-09  1:52       ` Chen Gang
2013-04-09  9:36         ` Chen Gang
2013-04-09  9:55           ` Chen Gang
2013-04-10  6:00           ` Chen Gang
2013-04-09  2:47     ` [PATCH v2] kernel: module: using strlcpy and strcpy " Chen Gang
2013-04-10  1:22       ` Rusty Russell
2013-04-10  4:13         ` [PATCH v3] " Chen Gang
2013-04-10  6:52           ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).