mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
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: https://github.com/nodejs/node/pull/42175 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
24487befb7
commit
3dcab2b30a
1 file changed
+2
-2
@@ -421,7 +421,7 @@ MaybeLocal<Object> GetLastIssuedCert(
|
||||
void AddFingerprintDigest(
|
||||
const unsigned char* md,
|
||||
unsigned int md_size,
|
||||
char fingerprint[3 * EVP_MAX_MD_SIZE + 1]) {
|
||||
char fingerprint[3 * EVP_MAX_MD_SIZE]) {
|
||||
unsigned int i;
|
||||
const char hex[] = "0123456789ABCDEF";
|
||||
|
||||
@@ -571,7 +571,7 @@ MaybeLocal<Value> GetFingerprintDigest(
|
||||
X509* cert) {
|
||||
unsigned char md[EVP_MAX_MD_SIZE];
|
||||
unsigned int md_size;
|
||||
char fingerprint[EVP_MAX_MD_SIZE * 3 + 1];
|
||||
char fingerprint[EVP_MAX_MD_SIZE * 3];
|
||||
|
||||
if (X509_digest(cert, method, md, &md_size)) {
|
||||
AddFingerprintDigest(md, md_size, fingerprint);
|
||||
|
||||
Reference in new issue
Block a user