Skip to content

Commit

Permalink
[qtmozembed] Guard against null certificate data. Contributes to JB#4…
Browse files Browse the repository at this point in the history
…9873

The nsIX509Cert::GetRawDER() call can fail and return a null data
pointer under certain circumstances. This wasn't being guarded against
and so had the potential to crash the browser when opening an HTTPS
page. This change performs checks before attempting to use the returned
value.
  • Loading branch information
llewelld committed May 8, 2020
1 parent 5517f46 commit b1f252b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/qmozsecurity.cpp
Expand Up @@ -288,10 +288,13 @@ void QMozSecurity::importState(const char *aStatus, unsigned int aState)
emissions << &QMozSecurity::protocolVersionChanged;
}

QSslCertificate serverCertificate;
uint32_t length;
char *data;
aServerCert->GetRawDER(&length, (uint8_t **)&data);
QSslCertificate serverCertificate = QSslCertificate(QByteArray(data, length), QSsl::EncodingFormat::Der);
nsresult rv = aServerCert->GetRawDER(&length, (uint8_t **)&data);
if (rv == NS_OK && data) {
serverCertificate = QSslCertificate(QByteArray(data, length), QSsl::EncodingFormat::Der);
}
if (m_serverCertificate != serverCertificate) {
m_serverCertificate = serverCertificate;
emissions << &QMozSecurity::serverCertificateChanged;
Expand Down

0 comments on commit b1f252b

Please sign in to comment.