浏览代码

thermal: cpu_cooling: use snprintf instead of sprintf

Limit the amount of bytes written to dev_name by
secure writing with snprintf.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Eduardo Valentin 12 年之前
父节点
当前提交
99871a714b
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      drivers/thermal/cpu_cooling.c

+ 2 - 1
drivers/thermal/cpu_cooling.c

@@ -458,7 +458,8 @@ struct thermal_cooling_device *cpufreq_cooling_register(
 		return ERR_PTR(-EINVAL);
 		return ERR_PTR(-EINVAL);
 	}
 	}
 
 
-	sprintf(dev_name, "thermal-cpufreq-%d", cpufreq_dev->id);
+	snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
+		 cpufreq_dev->id);
 
 
 	cool_dev = thermal_cooling_device_register(dev_name, cpufreq_dev,
 	cool_dev = thermal_cooling_device_register(dev_name, cpufreq_dev,
 						&cpufreq_cooling_ops);
 						&cpufreq_cooling_ops);