summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2008-05-15 22:52:41 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-16 03:20:06 +0200
commita76bfd0da2321ed0a978ccbef192856ce7ed687a (patch)
treeeb9e9b10f8b500bdf55831e780a2658a2486b715
parentSplit up 'do_initcalls()' into two simpler functions (diff)
downloadlinux-a76bfd0da2321ed0a978ccbef192856ce7ed687a.tar.xz
linux-a76bfd0da2321ed0a978ccbef192856ce7ed687a.zip
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 e662e1cfd434aa234b72fbc781f1d70211cb785b) 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: Cyrill Gorcunov <gorcunov@gmail.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--init/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/init/main.c b/init/main.c
index b8bcf6da8a77..f7fb20021d48 100644
--- a/init/main.c
+++ b/init/main.c
@@ -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]) {