summaryrefslogtreecommitdiffstats
path: root/libnetutils
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2015-02-17 19:27:51 -0800
committerYabin Cui <yabinc@google.com>2015-02-17 19:27:51 -0800
commite2d63af002a3b494f6bd464f2652b6e1997e7a52 (patch)
treed4b36bc9bcc5df83d82f657a9343bfb913dfc06c /libnetutils
parentf96c15000f849d4c3fef08f0145c61a4862c3833 (diff)
downloadsystem_core-e2d63af002a3b494f6bd464f2652b6e1997e7a52.zip
system_core-e2d63af002a3b494f6bd464f2652b6e1997e7a52.tar.gz
system_core-e2d63af002a3b494f6bd464f2652b6e1997e7a52.tar.bz2
Move sprintf to snprintf.
Bug: 19340053 Change-Id: Id0d866e6195ed4752b4be6081eeb2aab8b1dbe9a
Diffstat (limited to 'libnetutils')
-rw-r--r--libnetutils/dhcpclient.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libnetutils/dhcpclient.c b/libnetutils/dhcpclient.c
index a05b7cb..240a789 100644
--- a/libnetutils/dhcpclient.c
+++ b/libnetutils/dhcpclient.c
@@ -236,13 +236,13 @@ int decode_dhcp_msg(dhcp_msg *msg, int len, dhcp_info *info)
#if VERBOSE
-static void hex2str(char *buf, const unsigned char *array, int len)
+static void hex2str(char *buf, size_t buf_size, const unsigned char *array, int len)
{
int i;
char *cp = buf;
-
+ char *buf_end = buf + buf_size;
for (i = 0; i < len; i++) {
- cp += sprintf(cp, " %02x ", array[i]);
+ cp += snprintf(cp, buf_end - cp, " %02x ", array[i]);
}
}
@@ -278,7 +278,7 @@ void dump_dhcp_msg(dhcp_msg *msg, int len)
ALOGD("giaddr = %s", ipaddr(msg->giaddr));
c = msg->hlen > 16 ? 16 : msg->hlen;
- hex2str(buf, msg->chaddr, c);
+ hex2str(buf, sizeof(buf), msg->chaddr, c);
ALOGD("chaddr = {%s}", buf);
for (n = 0; n < 64; n++) {
@@ -327,7 +327,7 @@ void dump_dhcp_msg(dhcp_msg *msg, int len)
memcpy(buf, &x[2], n);
buf[n] = '\0';
} else {
- hex2str(buf, &x[2], optsz);
+ hex2str(buf, sizeof(buf), &x[2], optsz);
}
if (x[0] == OPT_MESSAGE_TYPE)
name = dhcp_type_to_name(x[2]);