summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorBP, Praveen <praveenbp@ti.com>2006-12-07 05:39:09 +0100
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-07 17:39:42 +0100
commitbd9b0bac6f601655044fc35978e26231dffee03e (patch)
treeb6cc16149e406704e1e124aa159671beb63b7a56 /kernel
parent[PATCH] synclink_gt: fix init error handling (diff)
downloadlinux-bd9b0bac6f601655044fc35978e26231dffee03e.tar.xz
linux-bd9b0bac6f601655044fc35978e26231dffee03e.zip
[PATCH] sysctl: string length calculated is wrong if it contains negative numbers
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 # (akpm: the bug is that 123456 gets truncated) 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. Signed-off-by: Praveen BP <praveenbp@ti.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sysctl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 7abe9704e75a..6d7147cf66bb 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1875,7 +1875,7 @@ static int __do_proc_dointvec(void *tbl_data, ctl_table *table,
p = buf;
if (*p == '-' && left > 1) {
neg = 1;
- left--, p++;
+ p++;
}
if (*p < '0' || *p > '9')
break;
@@ -2126,7 +2126,7 @@ static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write,
p = buf;
if (*p == '-' && left > 1) {
neg = 1;
- left--, p++;
+ p++;
}
if (*p < '0' || *p > '9')
break;