提交 95ce326e 编写于 作者: B bellard

buffer overflow fix - printf format fix


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@931 c046a42c-6fe2-441c-8c8c-71466251a162
上级 a5448a7d
...@@ -1437,7 +1437,7 @@ static void term_show_prompt(void) ...@@ -1437,7 +1437,7 @@ static void term_show_prompt(void)
static void term_print_cmdline (const char *cmdline) static void term_print_cmdline (const char *cmdline)
{ {
term_show_prompt(); term_show_prompt();
term_printf(cmdline); term_printf("%s", cmdline);
term_flush(); term_flush();
} }
...@@ -1521,7 +1521,8 @@ static void term_up_char(void) ...@@ -1521,7 +1521,8 @@ static void term_up_char(void)
} }
term_hist_entry--; term_hist_entry--;
if (term_hist_entry >= 0) { if (term_hist_entry >= 0) {
strcpy(term_cmd_buf, term_history[term_hist_entry]); pstrcpy(term_cmd_buf, sizeof(term_cmd_buf),
term_history[term_hist_entry]);
term_printf("\n"); term_printf("\n");
term_print_cmdline(term_cmd_buf); term_print_cmdline(term_cmd_buf);
term_cmd_buf_index = term_cmd_buf_size = strlen(term_cmd_buf); term_cmd_buf_index = term_cmd_buf_size = strlen(term_cmd_buf);
...@@ -1533,7 +1534,8 @@ static void term_down_char(void) ...@@ -1533,7 +1534,8 @@ static void term_down_char(void)
if (term_hist_entry == TERM_MAX_CMDS - 1 || term_hist_entry == -1) if (term_hist_entry == TERM_MAX_CMDS - 1 || term_hist_entry == -1)
return; return;
if (term_history[++term_hist_entry] != NULL) { if (term_history[++term_hist_entry] != NULL) {
strcpy(term_cmd_buf, term_history[term_hist_entry]); pstrcpy(term_cmd_buf, sizeof(term_cmd_buf),
term_history[term_hist_entry]);
} else { } else {
term_hist_entry = -1; term_hist_entry = -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册