[<prev] [next>] [day] [month] [year] [list]
Message-ID: <B2EAB41A1AF603458C6A01E3CC809C4402A65361@dbde01.ent.ti.com>
Date: Mon, 27 Nov 2006 13:36:54 +0530
From: "BP, Praveen" <praveenbp@...com>
To: <linux-kernel@...r.kernel.org>
Subject: [2.6 PATCH] sysctl: String length calculated is wrong if it contains negative numbers
Hi All,
In the functions do_proc_dointvec() and do_proc_doulongvec_minmax(),
there seems to be a bug in string length calculation if string contains
negative integer.
The console log given below explains the bug. Setting negative values
may not be a right thing to do for "console log level" but then the test
(given below) can be used to demonstrate the bug in the code.
# echo "-1 -1 -1 -123456" > /proc/sys/kernel/printk
# cat /proc/sys/kernel/printk
-1 -1 -1 -1234
#
# echo "-1 -1 -1 123456" > /proc/sys/kernel/printk
# cat /proc/sys/kernel/printk
-1 -1 -1 1234
#
It works as expected if string contains all +ve integers
# echo "1 2 3 4" > /proc/sys/kernel/printk
# cat /proc/sys/kernel/printk
1 2 3 4
#
The patch given below fixes the issue.
Patch is generated against linux-2.6.18.3
Signed-off-by: Praveen BP <praveenbp@...com>
sysctl.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
--- a/kernel/sysctl.c 2006-11-19 08:58:22.000000000 +0530
+++ b/kernel/sysctl.c 2006-11-24 17:33:23.000000000 +0530
@@ -1748,7 +1748,7 @@
p = buf;
if (*p == '-' && left > 1) {
neg = 1;
- left--, p++;
+ p++;
}
if (*p < '0' || *p > '9')
break;
@@ -1989,7 +1989,7 @@
p = buf;
if (*p == '-' && left > 1) {
neg = 1;
- left--, p++;
+ p++;
}
if (*p < '0' || *p > '9')
break;
Thanks,
Praveen.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists