Xiaotian Feng 1b0d300bd0 core_pattern: fix truncation by core_pattern handler with long parameters
We met a parameter truncated issue, consider following:
> echo "|/root/core_pattern_pipe_test %p /usr/libexec/blah-blah-blah \
%s %c %p %u %g 11 12345678901234567890123456789012345678 %t" > \
/proc/sys/kernel/core_pattern

This is okay because the strings is less than CORENAME_MAX_SIZE.  "cat
/proc/sys/kernel/core_pattern" shows the whole string.  but after we run
core_pattern_pipe_test in man page, we found last parameter was truncated
like below:

        argc[10]=<12807486>

The root cause is core_pattern allows % specifiers, which need to be
replaced during parse time, but the replace may expand the strings to
larger than CORENAME_MAX_SIZE.  So if the last parameter is % specifiers,
the replace code is using snprintf(out_ptr, out_end - out_ptr, ...), this
will write out of corename array.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Neil Horman <nhorman@tuxdriver.com>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-10-27 18:03:12 -07:00
..
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-06-16 18:05:05 +02:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-08-18 01:01:33 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:13 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:24:16 -04:00
2010-10-25 21:26:11 -04:00
2010-10-26 16:52:12 -07:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:27:18 -04:00
2010-10-25 21:26:11 -04:00
2010-10-21 18:48:04 +02:00
2010-10-25 21:26:14 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:11 -04:00
2010-10-25 21:26:15 -04:00
2010-10-15 15:53:27 +02:00
2010-08-18 08:35:46 -04:00
2010-10-25 21:27:18 -04:00
2010-10-25 21:26:11 -04:00
2010-10-26 16:52:13 -07:00
2010-10-25 21:26:11 -04:00
2010-08-18 08:35:47 -04:00
2010-08-18 08:35:48 -04:00
2010-08-09 16:48:44 -04:00
2010-10-25 21:27:18 -04:00
2010-08-09 16:47:43 -04:00