1Replace strncpy with memcpy
2
3since the length of data to
4be copied has already been determined with strlen(). Replace strncpy()
5with memcpy() to address the warning and optimize the code a little.
6
7| ippool_config.c:112:2: note: 'snprintf' output between 8 and 55 bytes into a destination of size 48
8|   112 |  snprintf(prompt, sizeof(prompt), "ippool-%s", server_name);
9|       |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10
11Upstream-Status: Pending
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13--- a/cli/cli_readline.c
14+++ b/cli/cli_readline.c
15@@ -257,10 +257,15 @@ static void cli_rl_display_wrapped_text(
16 	int pos;
17 	int in_ws;
18 	int i;
19+	int bufsize = sizeof(text_buf)/sizeof(text_buf[0]);
20
21 	if (left_margin == 0) {
22 		left_margin = 3;
23 	}
24+	if (left_margin > bufsize) {
25+		left_margin = bufsize;
26+	}
27+
28 	if (right_margin == 0) {
29 		right_margin = 78;;
30 	}
31@@ -271,7 +276,7 @@ static void cli_rl_display_wrapped_text(
32 	/* First copy the text heading to the buffer and add a "-", accounting for
33 	 * the specified left margin.
34 	 */
35-	strncpy(&text_buf[0], text1, left_margin - 3);
36+	memcpy(&text_buf[0], text1, left_margin - 3);
37 	for (pos = strlen(text1); pos < left_margin - 3; pos++) {
38 		text_buf[pos] = ' ';
39 	}
40