[PATCH 1/6] POWERPC: use KSYM_NAME_LEN

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: LKML <linux-kernel@...>
Cc: Ingo Molnar <mingo@...>, David Miller <davem@...>, Andrew Morton <akpm@...>, Paul Mackerras <paulus@...>, Peter Zijlstra <peterz@...>, Thomas Gleixner <tglx@...>
Date: Wednesday, January 23, 2008 - 1:38 pm

Use KSYM_NAME_LEN instead of numeric value.
Actually because of too small 'tmp' there is
a potential buffer overflow.

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

Index: linux-2.6.git/arch/powerpc/xmon/xmon.c
===================================================================
--- linux-2.6.git.orig/arch/powerpc/xmon/xmon.c	2008-01-23 19:04:42.000000000 +0300
+++ linux-2.6.git/arch/powerpc/xmon/xmon.c	2008-01-23 19:12:45.000000000 +0300
@@ -69,7 +69,7 @@ static unsigned long ndump = 64;
 static unsigned long nidump = 16;
 static unsigned long ncsum = 4096;
 static int termch;
-static char tmpstr[128];
+static char tmpstr[KSYM_NAME_LEN];
 
 #define JMP_BUF_LEN	23
 static long bus_error_jmp[JMP_BUF_LEN];
@@ -2354,7 +2354,7 @@ scanhex(unsigned long *vp)
 		}
 	} else if (c == '$') {
 		int i;
-		for (i=0; i<63; i++) {
+		for (i = 0; i < sizeof(tmpstr) / 2; i++) {
 			c = inchar();
 			if (isspace(c)) {
 				termch = c;
@@ -2467,7 +2467,7 @@ symbol_lookup(void)
 {
 	int type = inchar();
 	unsigned long addr;
-	static char tmp[64];
+	static char tmp[KSYM_NAME_LEN];
 
 	switch (type) {
 	case 'a':
@@ -2476,7 +2476,7 @@ symbol_lookup(void)
 		termch = 0;
 		break;
 	case 's':
-		getstring(tmp, 64);
+		getstring(tmp, sizeof(tmp));
 		if (setjmp(bus_error_jmp) == 0) {
 			catch_memory_errors = 1;
 			sync();
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/6] POWERPC: use KSYM_NAME_LEN, Cyrill Gorcunov, (Wed Jan 23, 1:38 pm)
Re: [PATCH 1/6] POWERPC: use KSYM_NAME_LEN, Paulo Marques, (Wed Jan 23, 2:26 pm)
Re: [PATCH 1/6] POWERPC: use KSYM_NAME_LEN, Cyrill Gorcunov, (Wed Jan 23, 2:43 pm)
Re: [PATCH 1/6] POWERPC: use KSYM_NAME_LEN, Paulo Marques, (Wed Jan 23, 2:59 pm)
Re: [PATCH 1/6] POWERPC: use KSYM_NAME_LEN, Cyrill Gorcunov, (Wed Jan 23, 3:07 pm)