1458. [cleanup] sprintf() -> snprintf().

This commit is contained in:
Mark Andrews
2003-04-11 07:25:31 +00:00
parent 935000aa6e
commit 806c235ecf
16 changed files with 83 additions and 69 deletions

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: lex.c,v 1.75 2002/03/11 05:38:27 marka Exp $ */
/* $Id: lex.c,v 1.76 2003/04/11 07:25:27 marka Exp $ */
#include <config.h>
@@ -251,8 +251,7 @@ isc_lex_openstream(isc_lex_t *lex, FILE *stream) {
REQUIRE(VALID_LEX(lex));
/* This is safe. */
sprintf(name, "stream-%p", stream);
snprintf(name, sizeof(name), "stream-%p", stream);
return (new_source(lex, ISC_TRUE, ISC_FALSE, stream, name));
}
@@ -267,8 +266,7 @@ isc_lex_openbuffer(isc_lex_t *lex, isc_buffer_t *buffer) {
REQUIRE(VALID_LEX(lex));
/* This is safe. */
sprintf(name, "buffer-%p", buffer);
snprintf(name, sizeof(name), "buffer-%p", buffer);
return (new_source(lex, ISC_FALSE, ISC_FALSE, buffer, name));
}

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: log.c,v 1.80 2002/11/29 01:42:18 marka Exp $ */
/* $Id: log.c,v 1.81 2003/04/11 07:25:28 marka Exp $ */
/* Principal Authors: DCL */
@@ -1492,18 +1492,19 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
if ((channel->flags & ISC_LOG_PRINTLEVEL) != 0 &&
level_string[0] == '\0') {
if (level < ISC_LOG_CRITICAL)
sprintf(level_string,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_LOG,
ISC_MSG_LEVEL,
"level %d: "),
level);
snprintf(level_string, sizeof(level_string),
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_LOG,
ISC_MSG_LEVEL,
"level %d: "),
level);
else if (level > ISC_LOG_DYNAMIC)
sprintf(level_string, "%s %d: ",
log_level_strings[0], level);
snprintf(level_string, sizeof(level_string),
"%s %d: ", log_level_strings[0],
level);
else
sprintf(level_string, "%s: ",
log_level_strings[-level]);
snprintf(level_string, sizeof(level_string),
"%s: ", log_level_strings[-level]);
}
/*

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: sockaddr.c,v 1.55 2002/10/24 03:52:33 marka Exp $ */
/* $Id: sockaddr.c,v 1.56 2003/04/11 07:25:28 marka Exp $ */
#include <config.h>
@@ -120,10 +120,10 @@ isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target) {
*/
switch (sockaddr->type.sa.sa_family) {
case AF_INET:
sprintf(pbuf, "%u", ntohs(sockaddr->type.sin.sin_port));
snprintf(pbuf, sizeof(pbuf), "%u", ntohs(sockaddr->type.sin.sin_port));
break;
case AF_INET6:
sprintf(pbuf, "%u", ntohs(sockaddr->type.sin6.sin6_port));
snprintf(pbuf, sizeof(pbuf), "%u", ntohs(sockaddr->type.sin6.sin6_port));
break;
default:
return (ISC_R_FAILURE);