summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Schmoller <jschmoller@xes-inc.com>2010-03-12 09:49:23 -0600
committerWolfgang Denk <wd@denx.de>2010-03-21 22:44:58 +0100
commit6475b9f91bd33bfd38418469cabdcfc0fefbd848 (patch)
treedc8baee5e589fac670329f570a91fec52dd9c38f
parente070a56c777f1fd05950e1bc63483c19decd6f78 (diff)
downloadu-boot-imx-6475b9f91bd33bfd38418469cabdcfc0fefbd848.zip
u-boot-imx-6475b9f91bd33bfd38418469cabdcfc0fefbd848.tar.gz
u-boot-imx-6475b9f91bd33bfd38418469cabdcfc0fefbd848.tar.bz2
console: Fix console buffer overrun
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>
-rw-r--r--common/main.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/main.c b/common/main.c
index c860b0b..6fec200 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)