test: replace sprintf() with snprintf()

There is zero risk of overflowing the buffer, it's just a good habit.
This commit is contained in:
Ben Noordhuis 2013-08-05 01:16:26 +02:00
parent d7a1ba85f2
commit 96f32a206b

View File

@ -76,9 +76,9 @@ void test_ip6_addr_scope(const char* ip6_addr,
if (strncmp(ip6_addr, "fe80::", 6) != 0) return; if (strncmp(ip6_addr, "fe80::", 6) != 0) return;
#ifdef _WIN32 #ifdef _WIN32
sprintf(scoped_addr, "%s%%%d", ip6_addr, iface_index); snprintf(scoped_addr, sizeof(scoped_addr), "%s%%%d", ip6_addr, iface_index);
#else #else
sprintf(scoped_addr, "%s%%%s", ip6_addr, device_name); snprintf(scoped_addr, sizeof(scoped_addr), "%s%%%s", ip6_addr, device_name);
#endif #endif
LOGF("Testing link-local address %s (iface_index: 0x%02x, device_name: %s)\n", LOGF("Testing link-local address %s (iface_index: 0x%02x, device_name: %s)\n",