Replace uses of sprintf(3) with snprintf(3).
At -00, the compiler warns about sprintf(3), and it is promoted to an
error by -Werror.
Change-Id: Ibb380d27d7eb09dda8ac785be2478d656b379190
diff --git a/libc/dns/nameser/ns_name.c b/libc/dns/nameser/ns_name.c
index e3759ab..3a202c1 100644
--- a/libc/dns/nameser/ns_name.c
+++ b/libc/dns/nameser/ns_name.c
@@ -43,12 +43,6 @@
#include <stdlib.h>
#include <limits.h>
-#ifdef SPRINTF_CHAR
-# define SPRINTF(x) ((int)strlen(sprintf/**/x))
-#else
-# define SPRINTF(x) (sprintf x)
-#endif
-
#define NS_TYPE_ELT 0x40 /* EDNS0 extended label type */
#define DNS_LABELTYPE_BITSTRING 0x41
@@ -1012,31 +1006,31 @@
return(-1);
cp++;
- i = SPRINTF((dn, "\\[x"));
+ i = snprintf(dn, eom - dn, "\\[x");
if (i < 0)
return (-1);
dn += i;
for (b = blen; b > 7; b -= 8, cp++) {
- i = SPRINTF((dn, "%02x", *cp & 0xff));
+ i = snprintf(dn, eom - dn, "%02x", *cp & 0xff);
if (i < 0)
return (-1);
dn += i;
}
if (b > 4) {
tc = *cp++;
- i = SPRINTF((dn, "%02x", tc & (0xff << (8 - b))));
+ i = snprintf(dn, eom - dn, "%02x", tc & (0xff << (8 - b)));
if (i < 0)
return (-1);
dn += i;
} else if (b > 0) {
tc = *cp++;
- i = SPRINTF((dn, "%1x",
- (((u_int32_t)tc >> 4) & 0x0f) & (0x0f << (4 - b))));
+ i = snprintf(dn, eom - dn, "%1x",
+ (((u_int32_t)tc >> 4) & 0x0f) & (0x0f << (4 - b)));
if (i < 0)
return (-1);
dn += i;
}
- i = SPRINTF((dn, "/%d]", blen));
+ i = snprintf(dn, eom - dn, "/%d]", blen);
if (i < 0)
return (-1);
dn += i;