diff options
author | Khem Raj <raj.khem@gmail.com> | 2019-12-26 09:17:59 -0800 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2019-12-28 00:11:47 -0800 |
commit | 81a7c640a96c3d8fb94632a973f814506a1d0f75 (patch) | |
tree | 8e118702a0f17ec93ecd1ed1ac8c975389aa910a | |
parent | 7b70af667aef657e3b5665f5b93368be02c6eda7 (diff) | |
download | meta-openembedded-81a7c640a96c3d8fb94632a973f814506a1d0f75.tar.gz |
ippool: Fix strncpy -Wformat-truncation warning
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Adrian Bunk <bunk@stusta.de>
-rw-r--r-- | meta-networking/recipes-daemons/ippool/ippool/strncpy-truncation.patch | 39 | ||||
-rw-r--r-- | meta-networking/recipes-daemons/ippool/ippool_1.3.bb | 1 |
2 files changed, 40 insertions, 0 deletions
diff --git a/meta-networking/recipes-daemons/ippool/ippool/strncpy-truncation.patch b/meta-networking/recipes-daemons/ippool/ippool/strncpy-truncation.patch new file mode 100644 index 0000000000..01e1da8703 --- /dev/null +++ b/meta-networking/recipes-daemons/ippool/ippool/strncpy-truncation.patch | |||
@@ -0,0 +1,39 @@ | |||
1 | Replace strncpy with memcpy | ||
2 | |||
3 | since the length of data to | ||
4 | be copied has already been determined with strlen(). Replace strncpy() | ||
5 | with 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 | |||
11 | Upstream-Status: Pending | ||
12 | Signed-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 | } | ||
diff --git a/meta-networking/recipes-daemons/ippool/ippool_1.3.bb b/meta-networking/recipes-daemons/ippool/ippool_1.3.bb index 6fa46904b3..3554e688ab 100644 --- a/meta-networking/recipes-daemons/ippool/ippool_1.3.bb +++ b/meta-networking/recipes-daemons/ippool/ippool_1.3.bb | |||
@@ -26,6 +26,7 @@ SRC_URI = "https://sourceforge.net/projects/openl2tp/files/${BPN}/${PV}/${BPN}-$ | |||
26 | file://0003-cli-Mark-return-of-strtol-as-long-int.patch \ | 26 | file://0003-cli-Mark-return-of-strtol-as-long-int.patch \ |
27 | file://0002-link-with-libtirpc.patch \ | 27 | file://0002-link-with-libtirpc.patch \ |
28 | file://0003-musl-fixes.patch \ | 28 | file://0003-musl-fixes.patch \ |
29 | file://strncpy-truncation.patch \ | ||
29 | " | 30 | " |
30 | 31 | ||
31 | LIC_FILES_CHKSUM = "file://LICENSE;md5=4c59283b82fc2b166455e0fc23c71c6f" | 32 | LIC_FILES_CHKSUM = "file://LICENSE;md5=4c59283b82fc2b166455e0fc23c71c6f" |