summaryrefslogtreecommitdiffstats
path: root/power
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2010-05-13 16:24:26 -0700
committerNick Kralevich <nnk@google.com>2010-05-13 17:38:54 -0700
commitc6cf19a688b6d1c068a6f6ee4c1302a333cd8518 (patch)
treee94bf0ebf50b089f194b84829740996cf88c7839 /power
parentbf871a3efb4f93cd05c9ebad1906074e246e6840 (diff)
downloadhardware_libhardware_legacy-c6cf19a688b6d1c068a6f6ee4c1302a333cd8518.zip
hardware_libhardware_legacy-c6cf19a688b6d1c068a6f6ee4c1302a333cd8518.tar.gz
hardware_libhardware_legacy-c6cf19a688b6d1c068a6f6ee4c1302a333cd8518.tar.bz2
Get rid of warnings when compiled with -Wformat-security
Change-Id: Ib0a56e508734b1eca8b6cf125fd07efefee854aa
Diffstat (limited to 'power')
-rw-r--r--power/power.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/power/power.c b/power/power.c
index 8dea0a2..1dac44b 100644
--- a/power/power.c
+++ b/power/power.c
@@ -149,7 +149,8 @@ set_last_user_activity_timeout(int64_t delay)
if (fd >= 0) {
char buf[32];
ssize_t len;
- len = sprintf(buf, "%d", ((int)(delay)));
+ len = snprintf(buf, sizeof(buf), "%d", ((int)(delay)));
+ buf[sizeof(buf) - 1] = '\0';
len = write(fd, buf, len);
close(fd);
return 0;
@@ -175,9 +176,11 @@ set_screen_state(int on)
char buf[32];
int len;
if(on)
- len = sprintf(buf, on_state);
+ len = snprintf(buf, sizeof(buf), "%s", on_state);
else
- len = sprintf(buf, off_state);
+ len = snprintf(buf, sizeof(buf), "%s", off_state);
+
+ buf[sizeof(buf) - 1] = '\0';
len = write(g_fds[REQUEST_STATE], buf, len);
if(len < 0) {
LOGE("Failed setting last user activity: g_error=%d\n", g_error);