[PATCH 24/30] thermal: cpu_cooling: use snprintf instead of sprintf

From: Eduardo Valentin
Date: Wed Apr 17 2013 - 13:21:19 EST


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

Cc: Zhang Rui <rui.zhang@xxxxxxxxx>
Cc: linux-pm@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Eduardo Valentin <eduardo.valentin@xxxxxx>
---
drivers/thermal/cpu_cooling.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index b55cfc2..b1f9a4d 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -465,7 +465,8 @@ cpufreq_cooling_register(const struct cpumask *clip_cpus)
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,
&cpufreq_cooling_ops);
--
1.8.2.1.342.gfa7285d

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/