Commit 6475b9f91bd33bfd38418469cabdcfc0fefbd848

Authored by John Schmoller
Committed by Wolfgang Denk
1 parent e070a56c77

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>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

... ... @@ -68,7 +68,7 @@
68 68  
69 69 #undef DEBUG_PARSER
70 70  
71   -char console_buffer[CONFIG_SYS_CBSIZE]; /* console I/O buffer */
  71 +char console_buffer[CONFIG_SYS_CBSIZE + 1]; /* console I/O buffer */
72 72  
73 73 static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen);
74 74 static char erase_seq[] = "\b \b"; /* erase sequence */
... ... @@ -546,7 +546,7 @@
546 546 unsigned hist_num = 0;
547 547  
548 548 char* hist_list[HIST_MAX];
549   -char hist_lines[HIST_MAX][HIST_SIZE];
  549 +char hist_lines[HIST_MAX][HIST_SIZE + 1]; /* Save room for NULL */
550 550  
551 551 #define add_idx_minus_one() ((hist_add_idx == 0) ? hist_max : hist_add_idx-1)
552 552