Skip to content

Commit 3dcab2b

Browse files
authored
crypto: fix fingerprint string size calculation
The function generating fingerprint strings never accesses more than EVP_MAX_MD_SIZE * 3 characters, including the terminating '\0'. PR-URL: #42175 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 24487be commit 3dcab2b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/crypto/crypto_common.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ MaybeLocal<Object> GetLastIssuedCert(
421421
void AddFingerprintDigest(
422422
const unsigned char* md,
423423
unsigned int md_size,
424-
char fingerprint[3 * EVP_MAX_MD_SIZE + 1]) {
424+
char fingerprint[3 * EVP_MAX_MD_SIZE]) {
425425
unsigned int i;
426426
const char hex[] = "0123456789ABCDEF";
427427

@@ -571,7 +571,7 @@ MaybeLocal<Value> GetFingerprintDigest(
571571
X509* cert) {
572572
unsigned char md[EVP_MAX_MD_SIZE];
573573
unsigned int md_size;
574-
char fingerprint[EVP_MAX_MD_SIZE * 3 + 1];
574+
char fingerprint[EVP_MAX_MD_SIZE * 3];
575575

576576
if (X509_digest(cert, method, md, &md_size)) {
577577
AddFingerprintDigest(md, md_size, fingerprint);

0 commit comments

Comments
 (0)