提交 a76bfd0d 编写于 作者: C Cyrill Gorcunov 提交者: Linus Torvalds

initcalls: Fix m68k build and possible buffer overflow

This patch fixes a build bug on m68k - gcc decides to emit a call to the
strlen library function, which we don't implement.

More importantly - my previous patch "init: don't lose initcall return
values" (commit e662e1cf) had introduced
potential buffer overflow by wrong calculation of string accumulator
size.

Use strlcat() instead, fixing both bugs.

Many thanks Andreas Schwab and Geert Uytterhoeven for helping
to catch and fix the bug.
Signed-off-by: NCyrill Gorcunov <gorcunov@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 e0df154f
......@@ -697,7 +697,7 @@ static void __init do_one_initcall(initcall_t fn)
{
int count = preempt_count();
ktime_t t0, t1, delta;
char msgbuf[40];
char msgbuf[64];
int result;
if (initcall_debug) {
......@@ -722,11 +722,11 @@ static void __init do_one_initcall(initcall_t fn)
sprintf(msgbuf, "error code %d ", result);
if (preempt_count() != count) {
strncat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
preempt_count() = count;
}
if (irqs_disabled()) {
strncat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
local_irq_enable();
}
if (msgbuf[0]) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册