Commit 95ce326e5b47b4b841849f8a2ac7b96d6e204dfb
1 parent
a5448a7d
buffer overflow fix - printf format fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@931 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
5 additions
and
3 deletions
monitor.c
... | ... | @@ -1437,7 +1437,7 @@ static void term_show_prompt(void) |
1437 | 1437 | static void term_print_cmdline (const char *cmdline) |
1438 | 1438 | { |
1439 | 1439 | term_show_prompt(); |
1440 | - term_printf(cmdline); | |
1440 | + term_printf("%s", cmdline); | |
1441 | 1441 | term_flush(); |
1442 | 1442 | } |
1443 | 1443 | |
... | ... | @@ -1521,7 +1521,8 @@ static void term_up_char(void) |
1521 | 1521 | } |
1522 | 1522 | term_hist_entry--; |
1523 | 1523 | if (term_hist_entry >= 0) { |
1524 | - strcpy(term_cmd_buf, term_history[term_hist_entry]); | |
1524 | + pstrcpy(term_cmd_buf, sizeof(term_cmd_buf), | |
1525 | + term_history[term_hist_entry]); | |
1525 | 1526 | term_printf("\n"); |
1526 | 1527 | term_print_cmdline(term_cmd_buf); |
1527 | 1528 | term_cmd_buf_index = term_cmd_buf_size = strlen(term_cmd_buf); |
... | ... | @@ -1533,7 +1534,8 @@ static void term_down_char(void) |
1533 | 1534 | if (term_hist_entry == TERM_MAX_CMDS - 1 || term_hist_entry == -1) |
1534 | 1535 | return; |
1535 | 1536 | if (term_history[++term_hist_entry] != NULL) { |
1536 | - strcpy(term_cmd_buf, term_history[term_hist_entry]); | |
1537 | + pstrcpy(term_cmd_buf, sizeof(term_cmd_buf), | |
1538 | + term_history[term_hist_entry]); | |
1537 | 1539 | } else { |
1538 | 1540 | term_hist_entry = -1; |
1539 | 1541 | } | ... | ... |