Skip to content

Commit 66be8e8

Browse files
committed
Add maximum integer length to ASN1Key.cpp
Values around 2 GB lead to abort() calls within Qt 5.
1 parent 1ee3285 commit 66be8e8

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/sshagent/ASN1Key.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace
8686

8787
VALIDATE_RETURN(nextTag(stream, tag, len));
8888

89-
if (tag != TAG_INT) {
89+
if (tag != TAG_INT || len > 1024 * 1024 * 10) {
9090
return false;
9191
}
9292

tests/TestOpenSSHKey.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,18 @@ void TestOpenSSHKey::testParseRSA()
177177
QCOMPARE(key.fingerprint(QCryptographicHash::Md5), QString("MD5:c2:26:5b:3d:62:19:56:b0:c3:67:99:7a:a6:4c:66:06"));
178178
}
179179

180+
void TestOpenSSHKey::testParseRSABroken()
181+
{
182+
const QString keyString = QString("-----BEGIN RSA PRIVATE KEY-----\n"
183+
"MAACAQAChH////8=\n"
184+
"-----END RSA PRIVATE KEY-----\n");
185+
186+
const QByteArray keyData = keyString.toLatin1();
187+
188+
OpenSSHKey key;
189+
QVERIFY(!key.parsePKCS1PEM(keyData));
190+
}
191+
180192
void TestOpenSSHKey::testParseRSACompare()
181193
{
182194
const QString oldKeyString = QString("-----BEGIN RSA PRIVATE KEY-----\n"

tests/TestOpenSSHKey.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ private slots:
3131
void testParse();
3232
void testParseDSA();
3333
void testParseRSA();
34+
void testParseRSABroken();
3435
void testParseRSACompare();
3536
void testParseECDSA256();
3637
void testParseECDSA384();

0 commit comments

Comments
 (0)