tools/power turbostat: fix possible sprintf buffer overflow
authorLen Brown <len.brown@intel.com>
Fri, 8 Dec 2017 22:38:17 +0000 (17:38 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Oct 2018 06:54:18 +0000 (08:54 +0200)
commit 46c2797826cc6d1ae36fcbd966e76f9fa1907eef upstream.

Signed-off-by: Len Brown <len.brown@intel.com>
Cc: Alakesh Haloi <alakeshh@amazon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/power/x86/turbostat/turbostat.c

index 1512086..7a1b20e 100644 (file)
@@ -1485,7 +1485,7 @@ int get_mp(int cpu, struct msr_counter *mp, unsigned long long *counterp)
                if (get_msr(cpu, mp->msr_num, counterp))
                        return -1;
        } else {
-               char path[128];
+               char path[128 + PATH_BYTES];
 
                if (mp->flags & SYSFS_PERCPU) {
                        sprintf(path, "/sys/devices/system/cpu/cpu%d/%s",