]> www.infradead.org Git - users/willy/xarray.git/commitdiff
tools/power/x86/intel-speed-select: Increase string size
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Fri, 5 Mar 2021 01:31:49 +0000 (17:31 -0800)
committerHans de Goede <hdegoede@redhat.com>
Wed, 7 Apr 2021 17:47:22 +0000 (19:47 +0200)
The current string size to print cpulist can accommodate upto 80
logical CPUs per package. But this limit is not enough. So increase
the string size. Also prevent buffer overflow, if the string size
reaches limit.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
tools/power/x86/intel-speed-select/isst-display.c

index 8e54ce47648e28f0ffc0c297e6fd0e7655f77f71..3bf1820c0da1184a2bcaf6df94c30c8725b6a95a 100644 (file)
@@ -25,10 +25,14 @@ static void printcpulist(int str_len, char *str, int mask_size,
                        index = snprintf(&str[curr_index],
                                         str_len - curr_index, ",");
                        curr_index += index;
+                       if (curr_index >= str_len)
+                               break;
                }
                index = snprintf(&str[curr_index], str_len - curr_index, "%d",
                                 i);
                curr_index += index;
+               if (curr_index >= str_len)
+                       break;
                first = 0;
        }
 }
@@ -64,10 +68,14 @@ static void printcpumask(int str_len, char *str, int mask_size,
                index = snprintf(&str[curr_index], str_len - curr_index, "%08x",
                                 mask[i]);
                curr_index += index;
+               if (curr_index >= str_len)
+                       break;
                if (i) {
                        strncat(&str[curr_index], ",", str_len - curr_index);
                        curr_index++;
                }
+               if (curr_index >= str_len)
+                       break;
        }
 
        free(mask);
@@ -185,7 +193,7 @@ static void _isst_pbf_display_information(int cpu, FILE *outf, int level,
                                          int disp_level)
 {
        char header[256];
-       char value[256];
+       char value[512];
 
        snprintf(header, sizeof(header), "speed-select-base-freq-properties");
        format_and_print(outf, disp_level, header, NULL);
@@ -349,7 +357,7 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
                                   struct isst_pkg_ctdp *pkg_dev)
 {
        char header[256];
-       char value[256];
+       char value[512];
        static int level;
        int i;