[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] libxc/xc_pm.c: fix an off-by-one error in xc_pm.c

libxc/xc_pm.c: fix an off-by-one error in xc_pm.c

This patch fixes the following compilation error.
In fact it is an off-by-one error.
> cc1: warnings being treated as errors
> xc_pm.c: In function 'xc_set_cpufreq_gov':
> xc_pm.c:288: error: array subscript is above array bounds

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

diff --git a/tools/libxc/xc_pm.c b/tools/libxc/xc_pm.c
--- a/tools/libxc/xc_pm.c
+++ b/tools/libxc/xc_pm.c
@@ -285,7 +285,7 @@ int xc_set_cpufreq_gov(int xc_handle, in
     sysctl.u.pm_op.cmd = SET_CPUFREQ_GOV;
     sysctl.u.pm_op.cpuid = cpuid;
     strncpy(scaling_governor, govname, CPUFREQ_NAME_LEN);
-    scaling_governor[CPUFREQ_NAME_LEN] = '\0';
+    scaling_governor[CPUFREQ_NAME_LEN - 1] = '\0';
     return xc_sysctl(xc_handle, &sysctl);


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.