summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bind/lib/isc/print.c
diff options
context:
space:
mode:
authortodd <todd@openbsd.org>2003-06-27 19:08:22 +0000
committertodd <todd@openbsd.org>2003-06-27 19:08:22 +0000
commit44c5f86991d56e224338eb71979bd544d0147a1c (patch)
tree22fdcdd89735d8b7d3b44281e8beec96481ae936 /usr.sbin/bind/lib/isc/print.c
parentprotos for userland build (diff)
downloadwireguard-openbsd-44c5f86991d56e224338eb71979bd544d0147a1c.tar.xz
wireguard-openbsd-44c5f86991d56e224338eb71979bd544d0147a1c.zip
string cleaning; "Put it in. If it breaks, tough" Theo.
work by me, useful feedback from krw, jakob, tedu, and tholo
Diffstat (limited to 'usr.sbin/bind/lib/isc/print.c')
-rw-r--r--usr.sbin/bind/lib/isc/print.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/usr.sbin/bind/lib/isc/print.c b/usr.sbin/bind/lib/isc/print.c
index ac2081d84b4..c15eb6c0fc9 100644
--- a/usr.sbin/bind/lib/isc/print.c
+++ b/usr.sbin/bind/lib/isc/print.c
@@ -20,7 +20,7 @@
#include <config.h>
#include <ctype.h>
-#include <stdio.h> /* for sprintf */
+#include <stdio.h> /* for snprintf */
#include <stdlib.h>
#define ISC__PRINT_SOURCE /* Used to get the isc_print_* prototypes. */
@@ -234,8 +234,8 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
head = "";
tmpui = tmpi;
}
- sprintf(buf, "%" ISC_PRINT_QUADFORMAT "u",
- tmpui);
+ snprintf(buf, sizeof(buf),
+ "%" ISC_PRINT_QUADFORMAT "u", tmpui);
goto printint;
case 'o':
if (q)
@@ -244,10 +244,10 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
tmpui = va_arg(ap, long int);
else
tmpui = va_arg(ap, int);
- sprintf(buf,
- alt ? "%#" ISC_PRINT_QUADFORMAT "o"
+ snprintf(buf, sizeof(buf),
+ alt ? "%#" ISC_PRINT_QUADFORMAT "o"
: "%" ISC_PRINT_QUADFORMAT "o",
- tmpui);
+ tmpui);
goto printint;
case 'u':
if (q)
@@ -256,8 +256,8 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
tmpui = va_arg(ap, unsigned long int);
else
tmpui = va_arg(ap, unsigned int);
- sprintf(buf, "%" ISC_PRINT_QUADFORMAT "u",
- tmpui);
+ snprintf(buf, sizeof(buf),
+ "%" ISC_PRINT_QUADFORMAT "u", tmpui);
goto printint;
case 'x':
if (q)
@@ -271,8 +271,8 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
if (precision > 2)
precision -= 2;
}
- sprintf(buf, "%" ISC_PRINT_QUADFORMAT "x",
- tmpui);
+ snprintf(buf, sizeof(buf),
+ "%" ISC_PRINT_QUADFORMAT "x", tmpui);
goto printint;
case 'X':
if (q)
@@ -286,8 +286,8 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
if (precision > 2)
precision -= 2;
}
- sprintf(buf, "%" ISC_PRINT_QUADFORMAT "X",
- tmpui);
+ snprintf(buf, sizeof(buf),
+ "%" ISC_PRINT_QUADFORMAT "X", tmpui);
goto printint;
printint:
if (precision != 0 || width != 0) {
@@ -413,7 +413,7 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
break;
case 'p':
v = va_arg(ap, void *);
- sprintf(buf, "%p", v);
+ snprintf(buf, sizeof(buf), "%p", v);
length = strlen(buf);
if (precision > length)
zeropad = precision - length;
@@ -489,9 +489,10 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
*/
if (precision > 512)
precision = 512;
- sprintf(fmt, "%%%s%s.%lu%s%c", alt ? "#" : "",
- plus ? "+" : space ? " " : "",
- precision, l ? "L" : "", *format);
+ snprintf(fmt, sizeof(fmt),
+ "%%%s%s.%lu%s%c", alt ? "#" : "",
+ plus ? "+" : space ? " " : "",
+ precision, l ? "L" : "", *format);
switch (*format) {
case 'e':
case 'E':
@@ -501,12 +502,12 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
#ifdef HAVE_LONG_DOUBLE
if (l) {
ldbl = va_arg(ap, long double);
- sprintf(buf, fmt, ldbl);
+ snprintf(buf, sizeof(buf), fmt, ldbl);
} else
#endif
{
dbl = va_arg(ap, double);
- sprintf(buf, fmt, dbl);
+ snprintf(buf, sizeof(buf), fmt, dbl);
}
length = strlen(buf);
if (width > 0) {