diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-11-07 12:47:12 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-11-07 12:47:12 +0100 |
commit | 8240fb9c736f91044cabbdde8c537b179fc4921e (patch) | |
tree | 49a4cc8dc683cf955d61b6618ad471860554ccb5 /security/manager/ssl/tests | |
parent | f9e04b54c2ccbc1f8e24b511003de09b4565193c (diff) | |
parent | 5c83a18cde404b5c0c9fba1d35f003d951ea32e2 (diff) | |
download | UXP-8240fb9c736f91044cabbdde8c537b179fc4921e.tar UXP-8240fb9c736f91044cabbdde8c537b179fc4921e.tar.gz UXP-8240fb9c736f91044cabbdde8c537b179fc4921e.tar.lz UXP-8240fb9c736f91044cabbdde8c537b179fc4921e.tar.xz UXP-8240fb9c736f91044cabbdde8c537b179fc4921e.zip |
Merge branch 'master' into Pale_Moon-release
# Conflicts:
# application/palemoon/config/version.txt
Diffstat (limited to 'security/manager/ssl/tests')
-rw-r--r-- | security/manager/ssl/tests/gtest/DeserializeCertTest.cpp | 86 | ||||
-rw-r--r-- | security/manager/ssl/tests/unit/test_cert_chains.js | 26 |
2 files changed, 112 insertions, 0 deletions
diff --git a/security/manager/ssl/tests/gtest/DeserializeCertTest.cpp b/security/manager/ssl/tests/gtest/DeserializeCertTest.cpp index 868ecdba6..c3a4115b3 100644 --- a/security/manager/ssl/tests/gtest/DeserializeCertTest.cpp +++ b/security/manager/ssl/tests/gtest/DeserializeCertTest.cpp @@ -94,3 +94,89 @@ TEST(psm_DeserializeCert, gecko46) ASSERT_EQ(NS_OK, rv); ASSERT_TRUE(cert); } + +TEST(psm_DeserializeCert, gecko64) +{ + // This is a serialization of nsITransportSecurityInfo from gecko 64. + // Deserialization should fail. + nsCString base64Serialization( + "FnhllAKWRHGAlo+ESXykKAAAAAAAAAAAwAAAAAAAAEaphjojH6pBabDSgSnsfLHeAAgAAgAAAAAAAAAAAAAAAAAAAAEAMQFmCjIm" + "kVxP+7sgiYWmMt8Fvc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9VNep+OkuE6N36B9KAA=="); + + nsCOMPtr<nsISupports> transportSecurityInfo; + nsresult rv = NS_DeserializeObject(base64Serialization, getter_AddRefs(transportSecurityInfo)); + ASSERT_EQ(NS_ERROR_FACTORY_NOT_REGISTERED, rv); + ASSERT_FALSE(transportSecurityInfo); +} diff --git a/security/manager/ssl/tests/unit/test_cert_chains.js b/security/manager/ssl/tests/unit/test_cert_chains.js index 8abcb4e65..dd1fc9369 100644 --- a/security/manager/ssl/tests/unit/test_cert_chains.js +++ b/security/manager/ssl/tests/unit/test_cert_chains.js @@ -31,9 +31,30 @@ function test_cert_equals() { " should return false"); } +function test_bad_cert_list_serialization() { + // Normally the serialization of an nsIX509CertList consists of some header + // junk (IIDs and whatnot), 4 bytes representing how many nsIX509Cert follow, + // and then the serialization of each nsIX509Cert. This serialization consists + // of the header junk for an nsIX509CertList with 1 "nsIX509Cert", but then + // instead of an nsIX509Cert, the subsequent bytes represent the serialization + // of another nsIX509CertList (with 0 nsIX509Cert). This test ensures that + // nsIX509CertList safely handles this unexpected input when deserializing. + const badCertListSerialization = + "lZ+xZWUXSH+rm9iRO+UxlwAAAAAAAAAAwAAAAAAAAEYAAAABlZ+xZWUXSH+rm9iRO+UxlwAAAAAA" + + "AAAAwAAAAAAAAEYAAAAA"; + let serHelper = Cc["@mozilla.org/network/serialization-helper;1"] + .getService(Ci.nsISerializationHelper); + throws(() => serHelper.deserializeObject(badCertListSerialization), + /NS_ERROR_UNEXPECTED/, + "deserializing a bogus nsIX509CertList should throw NS_ERROR_UNEXPECTED"); +} + function test_cert_list_serialization() { let certList = build_cert_chain(['default-ee', 'expired-ee']); + throws(() => certList.addCert(null), /NS_ERROR_ILLEGAL_VALUE/, + "trying to add a null cert to an nsIX509CertList should throw"); + // Serialize the cert list to a string let serHelper = Cc["@mozilla.org/network/serialization-helper;1"] .getService(Ci.nsISerializationHelper); @@ -78,6 +99,11 @@ function run_test() { // Test serialization of nsIX509CertList add_test(function() { + test_bad_cert_list_serialization(); + run_next_test(); + }); + + add_test(function() { test_cert_list_serialization(); run_next_test(); }); |