diff options
Diffstat (limited to 'recipes-extended/xen/files/tools-libxc-fix-strncpy-size.patch')
-rw-r--r-- | recipes-extended/xen/files/tools-libxc-fix-strncpy-size.patch | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/recipes-extended/xen/files/tools-libxc-fix-strncpy-size.patch b/recipes-extended/xen/files/tools-libxc-fix-strncpy-size.patch new file mode 100644 index 00000000..2d606cd3 --- /dev/null +++ b/recipes-extended/xen/files/tools-libxc-fix-strncpy-size.patch | |||
@@ -0,0 +1,44 @@ | |||
1 | From fa7789ef18bd2e716997937af71b2e4b5b00a159 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= | ||
3 | <marmarek@invisiblethingslab.com> | ||
4 | Date: Thu, 5 Apr 2018 03:50:49 +0200 | ||
5 | Subject: [PATCH] tools/libxc: fix strncpy size | ||
6 | MIME-Version: 1.0 | ||
7 | Content-Type: text/plain; charset=UTF-8 | ||
8 | Content-Transfer-Encoding: 8bit | ||
9 | |||
10 | gcc-8 warns about possible truncation of trailing '\0'. | ||
11 | Final character is overridden by '\0' anyway, so don't bother to copy | ||
12 | it. | ||
13 | |||
14 | This fixes compile failure: | ||
15 | |||
16 | xc_pm.c: In function 'xc_set_cpufreq_gov': | ||
17 | xc_pm.c:308:5: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation] | ||
18 | strncpy(scaling_governor, govname, CPUFREQ_NAME_LEN); | ||
19 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
20 | cc1: all warnings being treated as errors | ||
21 | |||
22 | Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> | ||
23 | Acked-by: Wei Liu <wei.liu2@citrix.com> | ||
24 | Release-Acked-by: Juergen Gross <jgross@suse.com> | ||
25 | --- | ||
26 | tools/libxc/xc_pm.c | 2 +- | ||
27 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
28 | |||
29 | diff --git a/tools/libxc/xc_pm.c b/tools/libxc/xc_pm.c | ||
30 | index 67e2418..6f8d548 100644 | ||
31 | --- a/tools/libxc/xc_pm.c | ||
32 | +++ b/tools/libxc/xc_pm.c | ||
33 | @@ -305,7 +305,7 @@ int xc_set_cpufreq_gov(xc_interface *xch, int cpuid, char *govname) | ||
34 | sysctl.cmd = XEN_SYSCTL_pm_op; | ||
35 | sysctl.u.pm_op.cmd = SET_CPUFREQ_GOV; | ||
36 | sysctl.u.pm_op.cpuid = cpuid; | ||
37 | - strncpy(scaling_governor, govname, CPUFREQ_NAME_LEN); | ||
38 | + strncpy(scaling_governor, govname, CPUFREQ_NAME_LEN - 1); | ||
39 | scaling_governor[CPUFREQ_NAME_LEN - 1] = '\0'; | ||
40 | |||
41 | return xc_sysctl(xch, &sysctl); | ||
42 | -- | ||
43 | 2.7.4 | ||
44 | |||