Skip to content

Commit 257bc96

Browse files
tniessendanielleadams
authored andcommitted
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 d45ca3d commit 257bc96

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
@@ -417,7 +417,7 @@ MaybeLocal<Object> GetLastIssuedCert(
417417
void AddFingerprintDigest(
418418
const unsigned char* md,
419419
unsigned int md_size,
420-
char fingerprint[3 * EVP_MAX_MD_SIZE + 1]) {
420+
char fingerprint[3 * EVP_MAX_MD_SIZE]) {
421421
unsigned int i;
422422
const char hex[] = "0123456789ABCDEF";
423423

@@ -567,7 +567,7 @@ MaybeLocal<Value> GetFingerprintDigest(
567567
X509* cert) {
568568
unsigned char md[EVP_MAX_MD_SIZE];
569569
unsigned int md_size;
570-
char fingerprint[EVP_MAX_MD_SIZE * 3 + 1];
570+
char fingerprint[EVP_MAX_MD_SIZE * 3];
571571

572572
if (X509_digest(cert, method, md, &md_size)) {
573573
AddFingerprintDigest(md, md_size, fingerprint);

0 commit comments

Comments
 (0)