tracing/filters: fix off-by-one bug
authorLi Zefan <lizf@cn.fujitsu.com>
Fri, 15 May 2009 03:07:56 +0000 (11:07 +0800)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 15 May 2009 03:55:12 +0000 (23:55 -0400)
We should leave the last slot for the ending '\0'.

[ Impact: fix possible crash when the length of an operand is 128 ]

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A0CDC8C.30602@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_events_filter.c

index 22c29984fe0e708d31e222acb6bbe569fd1623e9..a7430b16d243907d46032c923c89c65a50337c8b 100644 (file)
@@ -736,7 +736,7 @@ static inline void clear_operand_string(struct filter_parse_state *ps)
 
 static inline int append_operand_char(struct filter_parse_state *ps, char c)
 {
-       if (ps->operand.tail == MAX_FILTER_STR_VAL)
+       if (ps->operand.tail == MAX_FILTER_STR_VAL - 1)
                return -EINVAL;
 
        ps->operand.string[ps->operand.tail++] = c;