Skip to content

Commit

Permalink
Use snprintf() to make OpenBSD happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb James DeLisle committed Dec 10, 2012
1 parent 8dc5d31 commit 0f3cd1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions benc/serialization/json/JsonBencSerializer.c
Expand Up @@ -75,10 +75,10 @@ static int32_t serializeString(const struct Writer* writer,
chr = (uint8_t) string->bytes[i] & 0xFF;
/* Nonprinting chars, \ and " are hex'd */
if (chr < 126 && chr > 31 && chr != '\\' && chr != '"') {
sprintf(buffer, "%c", chr);
snprintf(buffer, 4, "%c", chr);
writer->write(buffer, 1, writer);
} else {
sprintf(buffer, "\\x%.2X", chr);
snprintf(buffer, 4, "\\x%.2X", chr);
writer->write(buffer, 4, writer);
}
}
Expand Down
7 changes: 2 additions & 5 deletions benc/serialization/standard/StandardBencSerializer.c
Expand Up @@ -41,11 +41,8 @@ static int32_t serializeGeneric(const struct Writer* writer,
static int32_t writeint64_t(const struct Writer* writer,
int64_t integer)
{
char buffer[32];
Bits_memset(buffer, 0, 32);

sprintf(buffer, "%" PRId64, integer);

char buffer[32] = {0};
snprintf(buffer, 32, "%" PRId64, integer);
return writer->write(buffer, strlen(buffer), writer);
}

Expand Down

0 comments on commit 0f3cd1c

Please sign in to comment.