summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYabin Cui2015-02-17 21:27:51 -0600
committerYabin Cui2015-02-17 21:27:51 -0600
commite2d63af002a3b494f6bd464f2652b6e1997e7a52 (patch)
treed4b36bc9bcc5df83d82f657a9343bfb913dfc06c /libnetutils
parentf96c15000f849d4c3fef08f0145c61a4862c3833 (diff)
downloadplatform-system-core-e2d63af002a3b494f6bd464f2652b6e1997e7a52.tar.gz
platform-system-core-e2d63af002a3b494f6bd464f2652b6e1997e7a52.tar.xz
platform-system-core-e2d63af002a3b494f6bd464f2652b6e1997e7a52.zip
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 a05b7cb0d..240a7891e 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)
236 236
237#if VERBOSE 237#if VERBOSE
238 238
239static void hex2str(char *buf, const unsigned char *array, int len) 239static void hex2str(char *buf, size_t buf_size, const unsigned char *array, int len)
240{ 240{
241 int i; 241 int i;
242 char *cp = buf; 242 char *cp = buf;
243 243 char *buf_end = buf + buf_size;
244 for (i = 0; i < len; i++) { 244 for (i = 0; i < len; i++) {
245 cp += sprintf(cp, " %02x ", array[i]); 245 cp += snprintf(cp, buf_end - cp, " %02x ", array[i]);
246 } 246 }
247} 247}
248 248
@@ -278,7 +278,7 @@ void dump_dhcp_msg(dhcp_msg *msg, int len)
278 ALOGD("giaddr = %s", ipaddr(msg->giaddr)); 278 ALOGD("giaddr = %s", ipaddr(msg->giaddr));
279 279
280 c = msg->hlen > 16 ? 16 : msg->hlen; 280 c = msg->hlen > 16 ? 16 : msg->hlen;
281 hex2str(buf, msg->chaddr, c); 281 hex2str(buf, sizeof(buf), msg->chaddr, c);
282 ALOGD("chaddr = {%s}", buf); 282 ALOGD("chaddr = {%s}", buf);
283 283
284 for (n = 0; n < 64; n++) { 284 for (n = 0; n < 64; n++) {
@@ -327,7 +327,7 @@ void dump_dhcp_msg(dhcp_msg *msg, int len)
327 memcpy(buf, &x[2], n); 327 memcpy(buf, &x[2], n);
328 buf[n] = '\0'; 328 buf[n] = '\0';
329 } else { 329 } else {
330 hex2str(buf, &x[2], optsz); 330 hex2str(buf, sizeof(buf), &x[2], optsz);
331 } 331 }
332 if (x[0] == OPT_MESSAGE_TYPE) 332 if (x[0] == OPT_MESSAGE_TYPE)
333 name = dhcp_type_to_name(x[2]); 333 name = dhcp_type_to_name(x[2]);