mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Safely use the strncat() function.
(closes issue #11958) Reported by: norman Patches: 20080209__bug11958.diff.txt uploaded by Corydon76 (license 14) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@106552 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user