Commit 689dfc9e authored by Zhang Rui's avatar Zhang Rui Committed by Hans de Goede

tools/power/x86/intel-speed-select: Use null-terminated string

strlen() and strtok() takes null-termimated strings as input.
Make sure these strings are null-terminated before using them.
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 8a44d275
...@@ -1583,6 +1583,7 @@ static int set_cpufreq_scaling_min_max_from_cpuinfo(int cpu, int cpuinfo_max, in ...@@ -1583,6 +1583,7 @@ static int set_cpufreq_scaling_min_max_from_cpuinfo(int cpu, int cpuinfo_max, in
if (fd < 0) if (fd < 0)
return fd; return fd;
min_freq[15] = '\0';
len = strlen(min_freq); len = strlen(min_freq);
ret = write(fd, min_freq, len); ret = write(fd, min_freq, len);
if (ret == -1) { if (ret == -1) {
...@@ -2015,6 +2016,7 @@ static void set_fact_enable(int arg) ...@@ -2015,6 +2016,7 @@ static void set_fact_enable(int arg)
if (len < 0) if (len < 0)
continue; continue;
sibling_list[127] = '\0';
cpu_str = strtok(sibling_list, ","); cpu_str = strtok(sibling_list, ",");
while (cpu_str != NULL) { while (cpu_str != NULL) {
int cpu; int cpu;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment