diff options
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 51423bf55..77d1489ff 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1932,9 +1932,10 @@ static char *cli_prompt(EditLine *el) if (color_used) { /* Force colors back to normal at end */ term_color_code(term_code, COLOR_WHITE, COLOR_BLACK, sizeof(term_code)); - if (strlen(term_code) > sizeof(prompt) - strlen(prompt)) { - strncat(prompt + sizeof(prompt) - strlen(term_code) - 1, term_code, strlen(term_code)); + if (strlen(term_code) > sizeof(prompt) - strlen(prompt) - 1) { + ast_copy_string(prompt + sizeof(prompt) - strlen(term_code) - 1, term_code, strlen(term_code) + 1); } else { + /* This looks wrong, but we've already checked the length of term_code to ensure it's safe */ strncat(p, term_code, sizeof(term_code)); } } |