diff options
Diffstat (limited to 'crypto/openssl/test/cmactest.c')
| -rw-r--r-- | crypto/openssl/test/cmactest.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/openssl/test/cmactest.c b/crypto/openssl/test/cmactest.c index cb2b273b0f4f..72f7a0d9366b 100644 --- a/crypto/openssl/test/cmactest.c +++ b/crypto/openssl/test/cmactest.c @@ -196,13 +196,15 @@ err: return ret; } +#define OSSL_HEX_CHARS_PER_BYTE 2 static char *pt(unsigned char *md, unsigned int len) { unsigned int i; - static char buf[80]; + static char buf[81]; - for (i = 0; i < len; i++) - sprintf(&(buf[i * 2]), "%02x", md[i]); + for (i = 0; i < len && (i + 1) * OSSL_HEX_CHARS_PER_BYTE < sizeof(buf); i++) + BIO_snprintf(buf + i * OSSL_HEX_CHARS_PER_BYTE, + OSSL_HEX_CHARS_PER_BYTE + 1, "%02x", md[i]); return buf; } |
