All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] console: Fix console buffer overrun
@ 2010-03-12 15:49 John Schmoller
  2010-03-12 15:49 ` [U-Boot] [PATCH 2/2] cmd history: Match history buffer size to console buffer John Schmoller
  2010-03-21 17:58 ` [U-Boot] [PATCH 1/2] console: Fix console buffer overrun Wolfgang Denk
  0 siblings, 2 replies; 4+ messages in thread
From: John Schmoller @ 2010-03-12 15:49 UTC (permalink / raw)
  To: u-boot

When CONFIG_SYS_CBSIZE equals MAX_CMDBUF_SIZE, a command string of
maximum length will overwrite part of the history buffer, causing the
board to die. Expand the console_buffer and hist_lines buffer by one
character each to hold the missing NULL char.

Signed-off-by: John Schmoller <jschmoller@xes-inc.com>
---
 common/main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/main.c b/common/main.c
index 10d8904..2a75550 100644
--- a/common/main.c
+++ b/common/main.c
@@ -68,7 +68,7 @@ static int abortboot(int);
 
 #undef DEBUG_PARSER
 
-char        console_buffer[CONFIG_SYS_CBSIZE];		/* console I/O buffer	*/
+char        console_buffer[CONFIG_SYS_CBSIZE + 1];	/* console I/O buffer	*/
 
 static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen);
 static char erase_seq[] = "\b \b";		/* erase sequence	*/
@@ -546,7 +546,7 @@ static int hist_cur = -1;
 unsigned hist_num = 0;
 
 char* hist_list[HIST_MAX];
-char hist_lines[HIST_MAX][HIST_SIZE];
+char hist_lines[HIST_MAX][HIST_SIZE + 1];	 /* Save room for NULL */
 
 #define add_idx_minus_one() ((hist_add_idx == 0) ? hist_max : hist_add_idx-1)
 
-- 
1.6.0.4

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

* [U-Boot] [PATCH 2/2] cmd history: Match history buffer size to console buffer
  2010-03-12 15:49 [U-Boot] [PATCH 1/2] console: Fix console buffer overrun John Schmoller
@ 2010-03-12 15:49 ` John Schmoller
  2010-03-21 17:57   ` Wolfgang Denk
  2010-03-21 17:58 ` [U-Boot] [PATCH 1/2] console: Fix console buffer overrun Wolfgang Denk
  1 sibling, 1 reply; 4+ messages in thread
From: John Schmoller @ 2010-03-12 15:49 UTC (permalink / raw)
  To: u-boot

Match history buffer size to console buffer size. History buffer size
was hard coded to 256, artificially limiting the command buffer size.
The history buffer now tracks CONFIG_SYS_CBSIZE.

Signed-off-by: John Schmoller <jschmoller@xes-inc.com>
---
 common/main.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/common/main.c b/common/main.c
index 2a75550..7ac657f 100644
--- a/common/main.c
+++ b/common/main.c
@@ -526,7 +526,7 @@ void reset_cmd_timeout(void)
 
 #define CTL_CH(c)		((c) - 'a' + 1)
 
-#define MAX_CMDBUF_SIZE		256
+#define MAX_CMDBUF_SIZE		CONFIG_SYS_CBSIZE
 
 #define CTL_BACKSPACE		('\b')
 #define DEL			((char)255)
-- 
1.6.0.4

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

* [U-Boot] [PATCH 2/2] cmd history: Match history buffer size to console buffer
  2010-03-12 15:49 ` [U-Boot] [PATCH 2/2] cmd history: Match history buffer size to console buffer John Schmoller
@ 2010-03-21 17:57   ` Wolfgang Denk
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Denk @ 2010-03-21 17:57 UTC (permalink / raw)
  To: u-boot

Dear John Schmoller,

In message <ca4aa654e79efc5c561fddeeea7c4d1806654b54.1268408614.git.jschmoller@xes-inc.com> you wrote:
> Match history buffer size to console buffer size. History buffer size
> was hard coded to 256, artificially limiting the command buffer size.
> The history buffer now tracks CONFIG_SYS_CBSIZE.
> 
> Signed-off-by: John Schmoller <jschmoller@xes-inc.com>
> ---
>  common/main.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Applied to "next" branch. Thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
There you go man, Keep as cool as you can. It riles them  to  believe
that you perceive the web they weave. Keep on being free!

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

* [U-Boot] [PATCH 1/2] console: Fix console buffer overrun
  2010-03-12 15:49 [U-Boot] [PATCH 1/2] console: Fix console buffer overrun John Schmoller
  2010-03-12 15:49 ` [U-Boot] [PATCH 2/2] cmd history: Match history buffer size to console buffer John Schmoller
@ 2010-03-21 17:58 ` Wolfgang Denk
  1 sibling, 0 replies; 4+ messages in thread
From: Wolfgang Denk @ 2010-03-21 17:58 UTC (permalink / raw)
  To: u-boot

Dear John Schmoller,

In message <69e2af90a136fea8e81009f4d58ffe28eddf7362.1268408614.git.jschmoller@xes-inc.com> you wrote:
> When CONFIG_SYS_CBSIZE equals MAX_CMDBUF_SIZE, a command string of
> maximum length will overwrite part of the history buffer, causing the
> board to die. Expand the console_buffer and hist_lines buffer by one
> character each to hold the missing NULL char.
> 
> Signed-off-by: John Schmoller <jschmoller@xes-inc.com>
> ---
>  common/main.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

Applied to "next" branch. Thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Every solution breeds new problems.

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

end of thread, other threads:[~2010-03-21 17:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-12 15:49 [U-Boot] [PATCH 1/2] console: Fix console buffer overrun John Schmoller
2010-03-12 15:49 ` [U-Boot] [PATCH 2/2] cmd history: Match history buffer size to console buffer John Schmoller
2010-03-21 17:57   ` Wolfgang Denk
2010-03-21 17:58 ` [U-Boot] [PATCH 1/2] console: Fix console buffer overrun Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.