am 72d72d91
: Merge "Replace uses of sprintf(3) with snprintf(3)."
* commit '72d72d91262fabe6bc169618ef3acb0721441cf0': Replace uses of sprintf(3) with snprintf(3).
This commit is contained in:
@@ -1949,7 +1949,7 @@ _resolv_set_nameservers_for_net(unsigned netid, const char** servers, int numser
|
||||
hints.ai_family = PF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_DGRAM; /*dummy*/
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
sprintf(sbuf, "%u", NAMESERVER_PORT);
|
||||
snprintf(sbuf, sizeof(sbuf), "%u", NAMESERVER_PORT);
|
||||
|
||||
index = 0;
|
||||
for (i = 0; i < numservers && i < MAXNS; i++) {
|
||||
|
@@ -126,14 +126,6 @@ __RCSID("$NetBSD: res_debug.c,v 1.13 2012/06/25 22:32:45 abs Exp $");
|
||||
#include <strings.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
|
||||
#ifdef SPRINTF_CHAR
|
||||
# define SPRINTF(x) strlen(sprintf/**/x)
|
||||
#else
|
||||
# define SPRINTF(x) sprintf x
|
||||
#endif
|
||||
|
||||
extern const char * const _res_opcodes[];
|
||||
extern const char * const _res_sectioncodes[];
|
||||
|
||||
@@ -588,7 +580,7 @@ sym_ntos(const struct res_sym *syms, int number, int *success) {
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(unname, "%d", number); /* XXX nonreentrant */
|
||||
snprintf(unname, sizeof(unname), "%d", number); /* XXX nonreentrant */
|
||||
if (success)
|
||||
*success = 0;
|
||||
return (unname);
|
||||
@@ -605,7 +597,7 @@ sym_ntop(const struct res_sym *syms, int number, int *success) {
|
||||
return (syms->humanname);
|
||||
}
|
||||
}
|
||||
sprintf(unname, "%d", number); /* XXX nonreentrant */
|
||||
snprintf(unname, sizeof(unname), "%d", number); /* XXX nonreentrant */
|
||||
if (success)
|
||||
*success = 0;
|
||||
return (unname);
|
||||
@@ -625,7 +617,7 @@ p_type(int type) {
|
||||
return (result);
|
||||
if (type < 0 || type > 0xffff)
|
||||
return ("BADTYPE");
|
||||
sprintf(typebuf, "TYPE%d", type);
|
||||
snprintf(typebuf, sizeof(typebuf), "TYPE%d", type);
|
||||
return (typebuf);
|
||||
}
|
||||
|
||||
@@ -661,7 +653,7 @@ p_class(int class) {
|
||||
return (result);
|
||||
if (class < 0 || class > 0xffff)
|
||||
return ("BADCLASS");
|
||||
sprintf(classbuf, "CLASS%d", class);
|
||||
snprintf(classbuf, sizeof(classbuf), "CLASS%d", class);
|
||||
return (classbuf);
|
||||
}
|
||||
|
||||
@@ -703,7 +695,7 @@ p_option(u_long option) {
|
||||
case RES_NO_NIBBLE2: return "no-nibble2";
|
||||
#endif
|
||||
/* XXX nonreentrant */
|
||||
default: sprintf(nbuf, "?0x%lx?", (u_long)option);
|
||||
default: snprintf(nbuf, sizeof(nbuf), "?0x%lx?", (u_long)option);
|
||||
return (nbuf);
|
||||
}
|
||||
}
|
||||
@@ -716,7 +708,7 @@ p_time(u_int32_t value) {
|
||||
static char nbuf[40]; /* XXX nonreentrant */
|
||||
|
||||
if (ns_format_ttl((u_long)value, nbuf, sizeof nbuf) < 0)
|
||||
sprintf(nbuf, "%u", value);
|
||||
snprintf(nbuf, sizeof(nbuf), "%u", value);
|
||||
return (nbuf);
|
||||
}
|
||||
|
||||
@@ -745,7 +737,7 @@ p_sockun(union res_sockaddr_union u, char *buf, size_t size) {
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
sprintf(ret, "[af%d]", u.sin.sin_family);
|
||||
snprintf(ret, sizeof(ret), "[af%d]", u.sin.sin_family);
|
||||
break;
|
||||
}
|
||||
if (size > 0U) {
|
||||
@@ -777,7 +769,7 @@ precsize_ntoa(u_int32_t prec)
|
||||
|
||||
val = mantissa * poweroften[exponent];
|
||||
|
||||
(void) sprintf(retbuf, "%lu.%.2lu", val/100, val%100);
|
||||
(void) snprintf(retbuf, sizeof(retbuf), "%lu.%.2lu", val/100, val%100);
|
||||
return (retbuf);
|
||||
}
|
||||
|
||||
@@ -1028,7 +1020,7 @@ loc_aton(const char *ascii, u_char *binary)
|
||||
|
||||
/* takes an on-the-wire LOC RR and formats it in a human readable format. */
|
||||
const char *
|
||||
loc_ntoa(const u_char *binary, char *ascii)
|
||||
loc_ntoa(const u_char *binary, char *ascii, size_t bufsiz)
|
||||
{
|
||||
static const char *error = "?";
|
||||
static char tmpbuf[sizeof
|
||||
@@ -1055,7 +1047,7 @@ loc_ntoa(const u_char *binary, char *ascii)
|
||||
ascii = tmpbuf;
|
||||
|
||||
if (versionval) {
|
||||
(void) sprintf(ascii, "; error: unknown LOC RR version");
|
||||
(void) snprintf(ascii, bufsiz, "; error: unknown LOC RR version");
|
||||
return (ascii);
|
||||
}
|
||||
|
||||
@@ -1114,7 +1106,7 @@ loc_ntoa(const u_char *binary, char *ascii)
|
||||
hpstr = strdup(precsize_ntoa((u_int32_t)hpval));
|
||||
vpstr = strdup(precsize_ntoa((u_int32_t)vpval));
|
||||
|
||||
sprintf(ascii,
|
||||
snprintf(ascii, bufsiz,
|
||||
"%d %.2d %.2d.%.3d %c %d %.2d %.2d.%.3d %c %s%d.%.2dm %sm %sm %sm",
|
||||
latdeg, latmin, latsec, latsecfrac, northsouth,
|
||||
longdeg, longmin, longsec, longsecfrac, eastwest,
|
||||
@@ -1180,7 +1172,7 @@ p_secstodate (u_long secs) {
|
||||
#endif
|
||||
mytime->tm_year += 1900;
|
||||
mytime->tm_mon += 1;
|
||||
sprintf(output, "%04d%02d%02d%02d%02d%02d",
|
||||
snprintf(output, sizeof(output), "%04d%02d%02d%02d%02d%02d",
|
||||
mytime->tm_year, mytime->tm_mon, mytime->tm_mday,
|
||||
mytime->tm_hour, mytime->tm_min, mytime->tm_sec);
|
||||
return (output);
|
||||
|
@@ -414,7 +414,7 @@ res_nquerydomain(res_state statp,
|
||||
RES_SET_H_ERRNO(statp, NO_RECOVERY);
|
||||
return (-1);
|
||||
}
|
||||
sprintf(nbuf, "%s.%s", name, domain);
|
||||
snprintf(nbuf, sizeof(nbuf), "%s.%s", name, domain);
|
||||
}
|
||||
return (res_nquery(statp, longname, class, type, answer, anslen));
|
||||
}
|
||||
|
Reference in New Issue
Block a user