Permalink
Browse files

Use snprintf() to make OpenBSD happy.

  • Loading branch information...
1 parent 8dc5d31 commit 0f3cd1c963ab50c46a208d3422f391a7d79d5ea2 Caleb James DeLisle committed Dec 10, 2012
@@ -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);
}
}
@@ -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);
}

0 comments on commit 0f3cd1c

Please sign in to comment.