Turbostat: replace sprintf with ssnprintf from common.h
authorVincent Brillault <git@lerya.net>
Thu, 21 Aug 2014 16:09:26 +0000 (18:09 +0200)
committerVincent Brillault <git@lerya.net>
Sat, 28 Feb 2015 06:35:40 +0000 (07:35 +0100)
src/turbostat.c

index 128950c..a003ca8 100644 (file)
@@ -273,7 +273,7 @@ get_msr(int cpu, off_t offset, unsigned long long *msr)
        char pathname[32];
        int fd;
 
-       sprintf(pathname, "/dev/cpu/%d/msr", cpu);
+       ssnprintf(pathname, 32, "/dev/cpu/%d/msr", cpu);
        fd = open(pathname, O_RDONLY);
        if (fd < 0)
                return -1;
@@ -640,7 +640,7 @@ get_num_ht_siblings(int cpu)
        int matches;
        char character;
 
-       sprintf(path, "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", cpu);
+       ssnprintf(path, 80, "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", cpu);
        filep = fopen(path, "r");
         if (!filep) {
                 ERROR("%s: open failed", path);