Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify digital signature after we have a signer/counter-signer to fix fileinfo crashes #249

Merged
merged 1 commit into from
Mar 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/fileformat/file_format/pe/pe_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,8 +975,6 @@ void PeFormat::loadCertificates()
return;
}

signatureVerified = verifySignature(p7);

// Find signer of the application and store its serial number.
X509 *signerCert = nullptr;
X509 *counterSignerCert = nullptr;
Expand Down Expand Up @@ -1021,6 +1019,12 @@ void PeFormat::loadCertificates()
return;
}

// Now that we know there is at least a signer or counter-signer, we can
// verify the signature. Do not try to verify the signature before
// verifying that there is at least a signer or counter-signer as 'p7' is
// empty in that case (#87).
signatureVerified = verifySignature(p7);

// Create hash table with key-value pair as subject-X509 certificate so we can easily lookup certificates by their subject name
std::unordered_map<std::string, X509*> subjectToCert;
for(int j = 0; j < sk_X509_num(certs); ++j)
Expand Down