param_sysfs_builtin memchr argument fix
PATCH 1/1 param_sysfs_builtin memchr argument fix
If memchr argument is longer than strlen(kp->name), there will be some weird result.
Signed-off-by Dave Young <[email protected]>
---params.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
kernel/params.c +8 -2
@@ -592,15 +592,21 @@ static void __init param_sysfs_builtin(vfor (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? */
Quoted 8 lines · Dave Young
If memchr argument is longer than
strlen(kp->name), there will be some weird result.Signed-off-by Dave Young <[email protected]>---
params.c| 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)
Hmm, you used diffstat without -p1?
kernel/params.c static void __init param_sysfs_builtin(v · line 598
Quoted 12 lines
diff -upr
linux/kernel/params.clinux.new/kernel/params.ckernel/params.c +2
-0@@ -592,15 +592,21 @@ static void __init param_sysfs_builtin(vfor (i=0 ; i < __stop___param - __start___param; i++) {char *dot; +int kplen; kp = &__start___param[i]; + kplen =strlen (kp->name);
strlen() returns a size_t value, which is unsigned. ;)
kernel/params.c static void __init param_sysfs_builtin(v · line 609
Quoted 13 lines
kernel/params.c +6
-2/* 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 ; - } + }
You add an extra whitespace in the end of the line.
Signature · 5 lines
I try to say goodbye and I choke. I try to walk away and I stumble. I play it off, but I’m dreaming of you. Though I try to hide it, it’s clear that my world crumbles when you are not here.