From 9e9f8b03d8a4ce52119a3583a522bd7b7ee383c3 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 22 Mar 2018 10:31:50 +0100 Subject: [PATCH] Fix Coverity Scan findings, missing return and bad strcpy() Signed-off-by: Joachim Nilsson --- examples/excallback.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/excallback.c b/examples/excallback.c index 4053246..015132a 100644 --- a/examples/excallback.c +++ b/examples/excallback.c @@ -134,6 +134,8 @@ main() rl_callback_read_char(); } } + + return 0; } void @@ -168,7 +170,8 @@ change_prompt(void) prompt = !prompt; /* save away the current contents of the line */ - strcpy(line_buf, rl_line_buffer); + strncpy(line_buf, rl_line_buffer, sizeof(line_buf)); + line_buf[sizeof(line_buf) - 1] = 0; /* install a new handler which will change the prompt and erase the current line */ rl_callback_handler_install(get_prompt(), process_line); @@ -179,7 +182,7 @@ change_prompt(void) /* redraw the current line - this is an undocumented function. It invokes the * redraw-current-line command. */ - rl_refresh_line(0, 0); + return rl_refresh_line(0, 0); } char *