From a2f37e4fd719722064438d5ca34f88a7fa9a5886 Mon Sep 17 00:00:00 2001 From: Raja M Date: Tue, 19 Apr 2016 23:55:14 +0530 Subject: More secure and compiler warning fix for sprintf into snprintf To fix GCC WARNINGS while building. or To support error free -D_FORTIFY_SOURCE=2 strict mode compilation. Change-Id: I999bd83785456a77247e5e1d708e2bdde2eb057b --- libcutils/sched_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libcutils') diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c index 6bba3a7b1..7bb8223be 100644 --- a/libcutils/sched_policy.c +++ b/libcutils/sched_policy.c @@ -306,7 +306,7 @@ int set_sched_policy(int tid, SchedPolicy policy) char thread_name[255]; int fd; - sprintf(statfile, "/proc/%d/stat", tid); + snprintf(statfile, sizeof(statfile), "/proc/%d/stat", tid); memset(thread_name, 0, sizeof(thread_name)); fd = open(statfile, O_RDONLY); -- cgit v1.2.3