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: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Zhang Rui 2023-01-12 14:43:37 +08:00 коммит произвёл Hans de Goede
Родитель 8a44d27542
Коммит 689dfc9e40
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -1583,6 +1583,7 @@ static int set_cpufreq_scaling_min_max_from_cpuinfo(int cpu, int cpuinfo_max, in
if (fd < 0)
return fd;
min_freq[15] = '\0';
len = strlen(min_freq);
ret = write(fd, min_freq, len);
if (ret == -1) {
@ -2015,6 +2016,7 @@ static void set_fact_enable(int arg)
if (len < 0)
continue;
sibling_list[127] = '\0';
cpu_str = strtok(sibling_list, ",");
while (cpu_str != NULL) {
int cpu;