gallium/aux/hud: Avoid possible buffer overflow
Limit the length of acceptable cpu names for use in hud_get_num_cpufreq in order to avoid a buffer overflow later in add_object when this name is copied into cpufreq_info::name. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105274 Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> Signed-off-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
@@ -207,8 +207,12 @@ hud_get_num_cpufreq(bool displayhelp)
|
||||
|
||||
while ((dp = readdir(dir)) != NULL) {
|
||||
|
||||
/* Avoid 'lo' and '..' and '.' */
|
||||
if (strlen(dp->d_name) <= 2)
|
||||
size_t d_name_len = strlen(dp->d_name);
|
||||
|
||||
/* Avoid 'lo' and '..' and '.', and avoid overlong names that
|
||||
* would result in a buffer overflow in add_object.
|
||||
*/
|
||||
if (d_name_len <= 2 || d_name_len > 15)
|
||||
continue;
|
||||
|
||||
if (sscanf(dp->d_name, "cpu%d\n", &cpu_index) != 1)
|
||||
|
Reference in New Issue
Block a user