Use snprintf() in findalldevstest.c.
Clang 10.0.1 in OpenBSD 6.9 (on MIPS64, although not on AArch64 or
AMD64) emitted a few warnings, which on this occasion did not stand for
an issue. Squelch these anyway by switching to snprintf(). While at it,
clarify the array size using a sizeof().
/usr/bin/ld: Dwarf Error: found dwarf version '0', this reader only
handles version 2 information.
/tmp/findalldevstest-807330.o: In function `main':
findalldevstest.c:(.text+0x6ec): warning: sprintf() is often misused,
please use snprintf()
(cherry picked from commit aa4163e6730e1863ce74ac406af0dd1b2f3dbfa2)
diff --git a/testprogs/findalldevstest.c b/testprogs/findalldevstest.c
index 092fd04..0629320 100644
--- a/testprogs/findalldevstest.c
+++ b/testprogs/findalldevstest.c
@@ -321,12 +321,12 @@
#define IPTOSBUFFERS 12
static char *iptos(bpf_u_int32 in)
{
- static char output[IPTOSBUFFERS][3*4+3+1];
+ static char output[IPTOSBUFFERS][sizeof("255.255.255.255")];
static short which;
u_char *p;
p = (u_char *)∈
which = (which + 1 == IPTOSBUFFERS ? 0 : which + 1);
- sprintf(output[which], "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
+ snprintf(output[which], sizeof(output[which]), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
return output[which];
}