public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] param_sysfs_builtin memchr argument fix
@ 2007-10-08  6:50 Dave Young
  2007-10-08  7:02 ` WANG Cong
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Young @ 2007-10-08  6:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, gregkh

If memchr argument is longer than strlen(kp->name), there will be some
weird result. 

Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 

---
params.c |   10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff -upr linux/kernel/params.c linux.new/kernel/params.c
--- linux/kernel/params.c	2007-10-08 14:30:06.000000000 +0800
+++ linux.new/kernel/params.c	2007-10-08 14:31:22.000000000 +0800
@@ -592,15 +592,21 @@ static void __init param_sysfs_builtin(v
 
 	for (i=0; i < __stop___param - __start___param; i++) {
 		char *dot;
+		int kplen;
 
 		kp = &__start___param[i];
+		kplen = strlen(kp->name);
 
 		/* We do not handle args without periods. */
-		dot = memchr(kp->name, '.', MAX_KBUILD_MODNAME);
+		if (kplen > MAX_KBUILD_MODNAME) {
+			DEBUGP("kernel parameter %s is too long\n", kp->name);
+			continue;
+		}
+		dot = memchr(kp->name, '.', kplen);
 		if (!dot) {
 			DEBUGP("couldn't find period in %s\n", kp->name);
 			continue;
-		}
+		} 
 		name_len = dot - kp->name;
 
  		/* new kbuild_modname? */

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [PATCH] param_sysfs_builtin memchr argument fix
@ 2007-10-08  7:17 Dave Young
  2007-10-08 16:13 ` Randy Dunlap
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Young @ 2007-10-08  7:17 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: linux-kernel, akpm, gregkh

Hi,
Thanks for comment.
fixed.

Regards
dave
-----

If memchr argument is longer than strlen(kp->name), there will be some
weird result.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 

---
kernel/params.c |    8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff -upr linux/kernel/params.c linux.new/kernel/params.c
--- linux/kernel/params.c	2007-10-08 14:30:06.000000000 +0800
+++ linux.new/kernel/params.c	2007-10-08 15:13:04.000000000 +0800
@@ -592,11 +592,17 @@ static void __init param_sysfs_builtin(v
 
 	for (i=0; i < __stop___param - __start___param; i++) {
 		char *dot;
+		size_t kplen;
 
 		kp = &__start___param[i];
+		kplen = strlen(kp->name);
 
 		/* We do not handle args without periods. */
-		dot = memchr(kp->name, '.', MAX_KBUILD_MODNAME);
+		if (kplen > MAX_KBUILD_MODNAME) {
+			DEBUGP("kernel parameter %s is too long\n", kp->name);
+			continue;
+		}
+		dot = memchr(kp->name, '.', kplen);
 		if (!dot) {
 			DEBUGP("couldn't find period in %s\n", kp->name);
 			continue;

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

end of thread, other threads:[~2007-10-09  1:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-08  6:50 [PATCH] param_sysfs_builtin memchr argument fix Dave Young
2007-10-08  7:02 ` WANG Cong
  -- strict thread matches above, loose matches on Subject: below --
2007-10-08  7:17 Dave Young
2007-10-08 16:13 ` Randy Dunlap
     [not found]   ` <a8e1da0710081807l74ca63ayf93183eac75193a@mail.gmail.com>
2007-10-09  1:21     ` Dave Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox