aboutsummaryrefslogtreecommitdiffstats
path: root/init/main.c
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2008-05-15 16:52:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-15 21:20:06 -0400
commita76bfd0da2321ed0a978ccbef192856ce7ed687a (patch)
treeeb9e9b10f8b500bdf55831e780a2658a2486b715 /init/main.c
parente0df154f45e40677781e971daec6c430cb34716b (diff)
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>
Diffstat (limited to 'init/main.c')
-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)
697{ 697{
698 int count = preempt_count(); 698 int count = preempt_count();
699 ktime_t t0, t1, delta; 699 ktime_t t0, t1, delta;
700 char msgbuf[40]; 700 char msgbuf[64];
701 int result; 701 int result;
702 702
703 if (initcall_debug) { 703 if (initcall_debug) {
@@ -722,11 +722,11 @@ static void __init do_one_initcall(initcall_t fn)
722 sprintf(msgbuf, "error code %d ", result); 722 sprintf(msgbuf, "error code %d ", result);
723 723
724 if (preempt_count() != count) { 724 if (preempt_count() != count) {
725 strncat(msgbuf, "preemption imbalance ", sizeof(msgbuf)); 725 strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
726 preempt_count() = count; 726 preempt_count() = count;
727 } 727 }
728 if (irqs_disabled()) { 728 if (irqs_disabled()) {
729 strncat(msgbuf, "disabled interrupts ", sizeof(msgbuf)); 729 strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
730 local_irq_enable(); 730 local_irq_enable();
731 } 731 }
732 if (msgbuf[0]) { 732 if (msgbuf[0]) {