public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] init - fix building bug and potential buffer overflow
@ 2008-05-14 15:44 Cyrill Gorcunov
  2008-05-15 17:58 ` Andrew Morton
  0 siblings, 1 reply; 14+ messages in thread
From: Cyrill Gorcunov @ 2008-05-14 15:44 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, Roman Zippel, Andreas Schwab, Geert Uytterhoeven,
	LKML

This patch does fix build bug on m68k wich does not have strncat in straight way.

What is more important - my previous patch

commit e662e1cfd434aa234b72fbc781f1d70211cb785b
Author: Cyrill Gorcunov <gorcunov@gmail.com>
Date:   Mon May 12 14:02:22 2008 -0700

    init: don't lose initcall return values

has introduced potential buffer overflow by wrong calculation
of string accumulator size.

Many thanks Andreas Schwab and Geert Uytterhoeven for helping
to catch and fix the bug.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---

Index: linux-2.6.git/init/main.c
===================================================================
--- linux-2.6.git.orig/init/main.c	2008-05-14 17:55:10.000000000 +0400
+++ linux-2.6.git/init/main.c	2008-05-14 19:11:18.000000000 +0400
@@ -702,7 +702,7 @@ static void __init do_initcalls(void)
 
 	for (call = __initcall_start; call < __initcall_end; call++) {
 		ktime_t t0, t1, delta;
-		char msgbuf[40];
+		char msgbuf[64];
 		int result;
 
 		if (initcall_debug) {
@@ -729,11 +729,11 @@ static void __init do_initcalls(void)
 			sprintf(msgbuf, "error code %d ", result);
 
 		if (preempt_count() != count) {
-			strncat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
+			strcat(msgbuf, "preemption imbalance ");
 			preempt_count() = count;
 		}
 		if (irqs_disabled()) {
-			strncat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
+			strcat(msgbuf, "disabled interrupts ");
 			local_irq_enable();
 		}
 		if (msgbuf[0]) {

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-05-16  7:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-14 15:44 [PATCH] init - fix building bug and potential buffer overflow Cyrill Gorcunov
2008-05-15 17:58 ` Andrew Morton
2008-05-15 18:05   ` Cyrill Gorcunov
2008-05-15 19:47     ` Geert Uytterhoeven
2008-05-15 20:22       ` Cyrill Gorcunov
2008-05-15 20:49         ` Andrew Morton
2008-05-15 21:15           ` Linus Torvalds
2008-05-15 21:45             ` Andrew Morton
2008-05-15 23:41               ` [PATCH] Add a void * alternative to print_fn_descriptor_symbol() Abhijit Menon-Sen
2008-05-16  1:47               ` [PATCH] init - fix building bug and potential buffer overflow Linus Torvalds
2008-05-15 22:44             ` Rene Herman
2008-05-16  3:29           ` Cyrill Gorcunov
2008-05-16  4:17             ` Cyrill Gorcunov
2008-05-16  7:00           ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox