diff options
Diffstat (limited to 'luni')
48 files changed, 1206 insertions, 253 deletions
diff --git a/luni/src/main/files/cacerts/04f60c28.0 b/luni/src/main/files/cacerts/04f60c28.0 new file mode 100644 index 0000000..dec2f4e --- /dev/null +++ b/luni/src/main/files/cacerts/04f60c28.0 @@ -0,0 +1,54 @@ +-----BEGIN CERTIFICATE----- +MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL +MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl +eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT +JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMjAx +MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgT +Ck5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVUaGUg +VVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlm +aWNhdGlvbiBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqflo +I+d61SRvU8Za2EurxtW20eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinng +o4N+LZfQYcTxmdwlkWOrfzCjtHDix6EznPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0G +A1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNVHQ8BAf8EBAMCAQYwDwYD +VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBBHU6+4WMB +zzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbW +RNZu9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg= +-----END CERTIFICATE----- +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 5c:8b:99:c5:5a:94:c5:d2:71:56:de:cd:89:80:cc:26 + Signature Algorithm: ecdsa-with-SHA384 + Issuer: C=US, ST=New Jersey, L=Jersey City, O=The USERTRUST Network, CN=USERTrust ECC Certification Authority + Validity + Not Before: Feb 1 00:00:00 2010 GMT + Not After : Jan 18 23:59:59 2038 GMT + Subject: C=US, ST=New Jersey, L=Jersey City, O=The USERTRUST Network, CN=USERTrust ECC Certification Authority + Subject Public Key Info: + Public Key Algorithm: id-ecPublicKey + Public-Key: (384 bit) + pub: + 04:1a:ac:54:5a:a9:f9:68:23:e7:7a:d5:24:6f:53: + c6:5a:d8:4b:ab:c6:d5:b6:d1:e6:73:71:ae:dd:9c: + d6:0c:61:fd:db:a0:89:03:b8:05:14:ec:57:ce:ee: + 5d:3f:e2:21:b3:ce:f7:d4:8a:79:e0:a3:83:7e:2d: + 97:d0:61:c4:f1:99:dc:25:91:63:ab:7f:30:a3:b4: + 70:e2:c7:a1:33:9c:f3:bf:2e:5c:53:b1:5f:b3:7d: + 32:7f:8a:34:e3:79:79 + ASN1 OID: secp384r1 + X509v3 extensions: + X509v3 Subject Key Identifier: + 3A:E1:09:86:D4:CF:19:C2:96:76:74:49:76:DC:E0:35:C6:63:63:9A + X509v3 Key Usage: critical + Certificate Sign, CRL Sign + X509v3 Basic Constraints: critical + CA:TRUE + Signature Algorithm: ecdsa-with-SHA384 + 30:65:02:30:36:67:a1:16:08:dc:e4:97:00:41:1d:4e:be:e1: + 63:01:cf:3b:aa:42:11:64:a0:9d:94:39:02:11:79:5c:7b:1d: + fa:64:b9:ee:16:42:b3:bf:8a:c2:09:c4:ec:e4:b1:4d:02:31: + 00:e9:2a:61:47:8c:52:4a:4b:4e:18:70:f6:d6:44:d6:6e:f5: + 83:ba:6d:58:bd:24:d9:56:48:ea:ef:c4:a2:46:81:88:6a:3a: + 46:d1:a9:9b:4d:c9:61:da:d1:5d:57:6a:18 +SHA1 Fingerprint=D1:CB:CA:5D:B2:D5:2A:7F:69:3B:67:4D:E5:F0:5A:1D:0C:95:7D:F0 diff --git a/luni/src/main/files/cacerts/0d69c7e1.0 b/luni/src/main/files/cacerts/0d69c7e1.0 new file mode 100644 index 0000000..84c387e --- /dev/null +++ b/luni/src/main/files/cacerts/0d69c7e1.0 @@ -0,0 +1,47 @@ +-----BEGIN CERTIFICATE----- +MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEk +MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpH +bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX +DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD +QSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprlOQcJ +FspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAw +DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61F +uOJAf/sKbvu+M8k8o4TVMAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGX +kPoUVy0D7O48027KqGx2vKLeuwIgJ6iFJzWbVsaj8kfSt24bAgAXqmemFZHe+pTs +ewv4n4Q= +-----END CERTIFICATE----- +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 2a:38:a4:1c:96:0a:04:de:42:b2:28:a5:0b:e8:34:98:02 + Signature Algorithm: ecdsa-with-SHA256 + Issuer: OU=GlobalSign ECC Root CA - R4, O=GlobalSign, CN=GlobalSign + Validity + Not Before: Nov 13 00:00:00 2012 GMT + Not After : Jan 19 03:14:07 2038 GMT + Subject: OU=GlobalSign ECC Root CA - R4, O=GlobalSign, CN=GlobalSign + Subject Public Key Info: + Public Key Algorithm: id-ecPublicKey + Public-Key: (256 bit) + pub: + 04:b8:c6:79:d3:8f:6c:25:0e:9f:2e:39:19:1c:03: + a4:ae:9a:e5:39:07:09:16:ca:63:b1:b9:86:f8:8a: + 57:c1:57:ce:42:fa:73:a1:f7:65:42:ff:1e:c1:00: + b2:6e:73:0e:ff:c7:21:e5:18:a4:aa:d9:71:3f:a8: + d4:b9:ce:8c:1d + ASN1 OID: prime256v1 + X509v3 extensions: + X509v3 Key Usage: critical + Certificate Sign, CRL Sign + X509v3 Basic Constraints: critical + CA:TRUE + X509v3 Subject Key Identifier: + 54:B0:7B:AD:45:B8:E2:40:7F:FB:0A:6E:FB:BE:33:C9:3C:A3:84:D5 + Signature Algorithm: ecdsa-with-SHA256 + 30:45:02:21:00:dc:92:a1:a0:13:a6:cf:03:b0:e6:c4:21:97: + 90:fa:14:57:2d:03:ec:ee:3c:d3:6e:ca:a8:6c:76:bc:a2:de: + bb:02:20:27:a8:85:27:35:9b:56:c6:a3:f2:47:d2:b7:6e:1b: + 02:00:17:aa:67:a6:15:91:de:fa:94:ec:7b:0b:f8:9f:84 +SHA1 Fingerprint=69:69:56:2E:40:80:F4:24:A1:E7:19:9F:14:BA:F3:EE:58:AB:6A:BB diff --git a/luni/src/main/files/cacerts/2add47b6.0 b/luni/src/main/files/cacerts/2add47b6.0 new file mode 100644 index 0000000..aa88539 --- /dev/null +++ b/luni/src/main/files/cacerts/2add47b6.0 @@ -0,0 +1,52 @@ +-----BEGIN CERTIFICATE----- +MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEk +MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpH +bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX +DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD +QSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu +MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6SFkc +8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8ke +hOvRnkmSh5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD +VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYI +KoZIzj0EAwMDaAAwZQIxAOVpEslu28YxuglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg +515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7yFz9SO8NdCKoCOJuxUnO +xwy8p2Fp8fc74SrL+SvzZpA3 +-----END CERTIFICATE----- +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 60:59:49:e0:26:2e:bb:55:f9:0a:77:8a:71:f9:4a:d8:6c + Signature Algorithm: ecdsa-with-SHA384 + Issuer: OU=GlobalSign ECC Root CA - R5, O=GlobalSign, CN=GlobalSign + Validity + Not Before: Nov 13 00:00:00 2012 GMT + Not After : Jan 19 03:14:07 2038 GMT + Subject: OU=GlobalSign ECC Root CA - R5, O=GlobalSign, CN=GlobalSign + Subject Public Key Info: + Public Key Algorithm: id-ecPublicKey + Public-Key: (384 bit) + pub: + 04:47:45:0e:96:fb:7d:5d:bf:e9:39:d1:21:f8:9f: + 0b:b6:d5:7b:1e:92:3a:48:59:1c:f0:62:31:2d:c0: + 7a:28:fe:1a:a7:5c:b3:b6:cc:97:e7:45:d4:58:fa: + d1:77:6d:43:a2:c0:87:65:34:0a:1f:7a:dd:eb:3c: + 33:a1:c5:9d:4d:a4:6f:41:95:38:7f:c9:1e:84:eb: + d1:9e:49:92:87:94:87:0c:3a:85:4a:66:9f:9d:59: + 93:4d:97:61:06:86:4a + ASN1 OID: secp384r1 + X509v3 extensions: + X509v3 Key Usage: critical + Certificate Sign, CRL Sign + X509v3 Basic Constraints: critical + CA:TRUE + X509v3 Subject Key Identifier: + 3D:E6:29:48:9B:EA:07:CA:21:44:4A:26:DE:6E:DE:D2:83:D0:9F:59 + Signature Algorithm: ecdsa-with-SHA384 + 30:65:02:31:00:e5:69:12:c9:6e:db:c6:31:ba:09:41:e1:97: + f8:fb:fd:9a:e2:7d:12:c9:ed:7c:64:d3:cb:05:25:8b:56:d9: + a0:e7:5e:5d:4e:0b:83:9c:5b:76:29:a0:09:26:21:6a:62:02: + 30:71:d2:b5:8f:5c:ea:3b:e1:78:09:85:a8:75:92:3b:c8:5c: + fd:48:ef:0d:74:22:a8:08:e2:6e:c5:49:ce:c7:0c:bc:a7:61: + 69:f1:f7:3b:e1:2a:cb:f9:2b:f3:66:90:37 +SHA1 Fingerprint=1F:24:C6:30:CD:A4:18:EF:20:69:FF:AD:4F:DD:5F:46:3A:1B:69:AA diff --git a/luni/src/main/files/cacerts/35105088.0 b/luni/src/main/files/cacerts/35105088.0 new file mode 100644 index 0000000..3728c3b --- /dev/null +++ b/luni/src/main/files/cacerts/35105088.0 @@ -0,0 +1,123 @@ +-----BEGIN CERTIFICATE----- +MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB +iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl +cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV +BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw +MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV +BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU +aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy +dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK +AoICAQCAEmUXNg7D2wiz0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B +3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2jY0K2dvKpOyuR+OJv0OwWIJAJPuLodMkY +tJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFnRghRy4YUVD+8M/5+bJz/ +Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O+T23LLb2 +VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT +79uq/nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6 +c0Plfg6lZrEpfDKEY1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmT +Yo61Zs8liM2EuLE/pDkP2QKe6xJMlXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97l +c6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8yexDJtC/QV9AqURE9JnnV4ee +UB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+eLf8ZxXhyVeE +Hg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd +BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8G +A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPF +Up/L+M+ZBn8b2kMVn54CVVeWFPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KO +VWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ7l8wXEskEVX/JJpuXior7gtNn3/3 +ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQEg9zKC7F4iRO/Fjs +8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM8WcR +iQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYze +Sf7dNXGiFSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZ +XHlKYC6SQK5MNyosycdiyA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/ +qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB +VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB +L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG +jjxDah2nGN59PRbxYvnKkKj9 +-----END CERTIFICATE----- +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 01:fd:6d:30:fc:a3:ca:51:a8:1b:bc:64:0e:35:03:2d + Signature Algorithm: sha384WithRSAEncryption + Issuer: C=US, ST=New Jersey, L=Jersey City, O=The USERTRUST Network, CN=USERTrust RSA Certification Authority + Validity + Not Before: Feb 1 00:00:00 2010 GMT + Not After : Jan 18 23:59:59 2038 GMT + Subject: C=US, ST=New Jersey, L=Jersey City, O=The USERTRUST Network, CN=USERTrust RSA Certification Authority + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (4096 bit) + Modulus: + 00:80:12:65:17:36:0e:c3:db:08:b3:d0:ac:57:0d: + 76:ed:cd:27:d3:4c:ad:50:83:61:e2:aa:20:4d:09: + 2d:64:09:dc:ce:89:9f:cc:3d:a9:ec:f6:cf:c1:dc: + f1:d3:b1:d6:7b:37:28:11:2b:47:da:39:c6:bc:3a: + 19:b4:5f:a6:bd:7d:9d:a3:63:42:b6:76:f2:a9:3b: + 2b:91:f8:e2:6f:d0:ec:16:20:90:09:3e:e2:e8:74: + c9:18:b4:91:d4:62:64:db:7f:a3:06:f1:88:18:6a: + 90:22:3c:bc:fe:13:f0:87:14:7b:f6:e4:1f:8e:d4: + e4:51:c6:11:67:46:08:51:cb:86:14:54:3f:bc:33: + fe:7e:6c:9c:ff:16:9d:18:bd:51:8e:35:a6:a7:66: + c8:72:67:db:21:66:b1:d4:9b:78:03:c0:50:3a:e8: + cc:f0:dc:bc:9e:4c:fe:af:05:96:35:1f:57:5a:b7: + ff:ce:f9:3d:b7:2c:b6:f6:54:dd:c8:e7:12:3a:4d: + ae:4c:8a:b7:5c:9a:b4:b7:20:3d:ca:7f:22:34:ae: + 7e:3b:68:66:01:44:e7:01:4e:46:53:9b:33:60:f7: + 94:be:53:37:90:73:43:f3:32:c3:53:ef:db:aa:fe: + 74:4e:69:c7:6b:8c:60:93:de:c4:c7:0c:df:e1:32: + ae:cc:93:3b:51:78:95:67:8b:ee:3d:56:fe:0c:d0: + 69:0f:1b:0f:f3:25:26:6b:33:6d:f7:6e:47:fa:73: + 43:e5:7e:0e:a5:66:b1:29:7c:32:84:63:55:89:c4: + 0d:c1:93:54:30:19:13:ac:d3:7d:37:a7:eb:5d:3a: + 6c:35:5c:db:41:d7:12:da:a9:49:0b:df:d8:80:8a: + 09:93:62:8e:b5:66:cf:25:88:cd:84:b8:b1:3f:a4: + 39:0f:d9:02:9e:eb:12:4c:95:7c:f3:6b:05:a9:5e: + 16:83:cc:b8:67:e2:e8:13:9d:cc:5b:82:d3:4c:b3: + ed:5b:ff:de:e5:73:ac:23:3b:2d:00:bf:35:55:74: + 09:49:d8:49:58:1a:7f:92:36:e6:51:92:0e:f3:26: + 7d:1c:4d:17:bc:c9:ec:43:26:d0:bf:41:5f:40:a9: + 44:44:f4:99:e7:57:87:9e:50:1f:57:54:a8:3e:fd: + 74:63:2f:b1:50:65:09:e6:58:42:2e:43:1a:4c:b4: + f0:25:47:59:fa:04:1e:93:d4:26:46:4a:50:81:b2: + de:be:78:b7:fc:67:15:e1:c9:57:84:1e:0f:63:d6: + e9:62:ba:d6:5f:55:2e:ea:5c:c6:28:08:04:25:39: + b8:0e:2b:a9:f2:4c:97:1c:07:3f:0d:52:f5:ed:ef: + 2f:82:0f + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Key Identifier: + 53:79:BF:5A:AA:2B:4A:CF:54:80:E1:D8:9B:C0:9D:F2:B2:03:66:CB + X509v3 Key Usage: critical + Certificate Sign, CRL Sign + X509v3 Basic Constraints: critical + CA:TRUE + Signature Algorithm: sha384WithRSAEncryption + 5c:d4:7c:0d:cf:f7:01:7d:41:99:65:0c:73:c5:52:9f:cb:f8: + cf:99:06:7f:1b:da:43:15:9f:9e:02:55:57:96:14:f1:52:3c: + 27:87:94:28:ed:1f:3a:01:37:a2:76:fc:53:50:c0:84:9b:c6: + 6b:4e:ba:8c:21:4f:a2:8e:55:62:91:f3:69:15:d8:bc:88:e3: + c4:aa:0b:fd:ef:a8:e9:4b:55:2a:06:20:6d:55:78:29:19:ee: + 5f:30:5c:4b:24:11:55:ff:24:9a:6e:5e:2a:2b:ee:0b:4d:9f: + 7f:f7:01:38:94:14:95:43:07:09:fb:60:a9:ee:1c:ab:12:8c: + a0:9a:5e:a7:98:6a:59:6d:8b:3f:08:fb:c8:d1:45:af:18:15: + 64:90:12:0f:73:28:2e:c5:e2:24:4e:fc:58:ec:f0:f4:45:fe: + 22:b3:eb:2f:8e:d2:d9:45:61:05:c1:97:6f:a8:76:72:8f:8b: + 8c:36:af:bf:0d:05:ce:71:8d:e6:a6:6f:1f:6c:a6:71:62:c5: + d8:d0:83:72:0c:f1:67:11:89:0c:9c:13:4c:72:34:df:bc:d5: + 71:df:aa:71:dd:e1:b9:6c:8c:3c:12:5d:65:da:bd:57:12:b6: + 43:6b:ff:e5:de:4d:66:11:51:cf:99:ae:ec:17:b6:e8:71:91: + 8c:de:49:fe:dd:35:71:a2:15:27:94:1c:cf:61:e3:26:bb:6f: + a3:67:25:21:5d:e6:dd:1d:0b:2e:68:1b:3b:82:af:ec:83:67: + 85:d4:98:51:74:b1:b9:99:80:89:ff:7f:78:19:5c:79:4a:60: + 2e:92:40:ae:4c:37:2a:2c:c9:c7:62:c8:0e:5d:f7:36:5b:ca: + e0:25:25:01:b4:dd:1a:07:9c:77:00:3f:d0:dc:d5:ec:3d:d4: + fa:bb:3f:cc:85:d6:6f:7f:a9:2d:df:b9:02:f7:f5:97:9a:b5: + 35:da:c3:67:b0:87:4a:a9:28:9e:23:8e:ff:5c:27:6b:e1:b0: + 4f:f3:07:ee:00:2e:d4:59:87:cb:52:41:95:ea:f4:47:d7:ee: + 64:41:55:7c:8d:59:02:95:dd:62:9d:c2:b9:ee:5a:28:74:84: + a5:9b:b7:90:c7:0c:07:df:f5:89:36:74:32:d6:28:c1:b0:b0: + 0b:e0:9c:4c:c3:1c:d6:fc:e3:69:b5:47:46:81:2f:a2:82:ab: + d3:63:44:70:c4:8d:ff:2d:33:ba:ad:8f:7b:b5:70:88:ae:3e: + 19:cf:40:28:d8:fc:c8:90:bb:5d:99:22:f5:52:e6:58:c5:1f: + 88:31:43:ee:88:1d:d7:c6:8e:3c:43:6a:1d:a7:18:de:7d:3d: + 16:f1:62:f9:ca:90:a8:fd +SHA1 Fingerprint=2B:8F:1B:57:33:0D:BB:A2:D0:7A:6C:51:F7:0E:E9:0D:DA:B9:AD:8E diff --git a/luni/src/main/files/cacerts/d4c339cb.0 b/luni/src/main/files/cacerts/d4c339cb.0 new file mode 100644 index 0000000..3f5e924 --- /dev/null +++ b/luni/src/main/files/cacerts/d4c339cb.0 @@ -0,0 +1,123 @@ +-----BEGIN CERTIFICATE----- +MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB +hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G +A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV +BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5 +MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgT +EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR +Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR +6FSS0gpWsawNJN3Fz0RndJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8X +pz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZFGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC +9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+5eNu/Nio5JIk2kNrYrhV +/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pGx8cgoLEf +Zd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z ++pUX2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7w +qP/0uK3pN/u6uPQLOvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZah +SL0896+1DSJMwBGB7FY79tOi4lu3sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVIC +u9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+CGCe01a60y1Dma/RMhnEw6abf +Fobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5WdYgGq/yapiq +crxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E +FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB +/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvl +wFTPoCWOAvn9sKIN9SCYPBMtrFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM +4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV +2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSgtZx8jb8uk2Intzna +FxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwWsRqZ +CuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiK +boHGhfKppC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmcke +jkk9u+UJueBPSZI9FoJAzMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yL +S0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb +QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl +0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB +NVOFBkpdn627G190 +-----END CERTIFICATE----- +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 4c:aa:f9:ca:db:63:6f:e0:1f:f7:4e:d8:5b:03:86:9d + Signature Algorithm: sha384WithRSAEncryption + Issuer: C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Certification Authority + Validity + Not Before: Jan 19 00:00:00 2010 GMT + Not After : Jan 18 23:59:59 2038 GMT + Subject: C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Certification Authority + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (4096 bit) + Modulus: + 00:91:e8:54:92:d2:0a:56:b1:ac:0d:24:dd:c5:cf: + 44:67:74:99:2b:37:a3:7d:23:70:00:71:bc:53:df: + c4:fa:2a:12:8f:4b:7f:10:56:bd:9f:70:72:b7:61: + 7f:c9:4b:0f:17:a7:3d:e3:b0:04:61:ee:ff:11:97: + c7:f4:86:3e:0a:fa:3e:5c:f9:93:e6:34:7a:d9:14: + 6b:e7:9c:b3:85:a0:82:7a:76:af:71:90:d7:ec:fd: + 0d:fa:9c:6c:fa:df:b0:82:f4:14:7e:f9:be:c4:a6: + 2f:4f:7f:99:7f:b5:fc:67:43:72:bd:0c:00:d6:89: + eb:6b:2c:d3:ed:8f:98:1c:14:ab:7e:e5:e3:6e:fc: + d8:a8:e4:92:24:da:43:6b:62:b8:55:fd:ea:c1:bc: + 6c:b6:8b:f3:0e:8d:9a:e4:9b:6c:69:99:f8:78:48: + 30:45:d5:ad:e1:0d:3c:45:60:fc:32:96:51:27:bc: + 67:c3:ca:2e:b6:6b:ea:46:c7:c7:20:a0:b1:1f:65: + de:48:08:ba:a4:4e:a9:f2:83:46:37:84:eb:e8:cc: + 81:48:43:67:4e:72:2a:9b:5c:bd:4c:1b:28:8a:5c: + 22:7b:b4:ab:98:d9:ee:e0:51:83:c3:09:46:4e:6d: + 3e:99:fa:95:17:da:7c:33:57:41:3c:8d:51:ed:0b: + b6:5c:af:2c:63:1a:df:57:c8:3f:bc:e9:5d:c4:9b: + af:45:99:e2:a3:5a:24:b4:ba:a9:56:3d:cf:6f:aa: + ff:49:58:be:f0:a8:ff:f4:b8:ad:e9:37:fb:ba:b8: + f4:0b:3a:f9:e8:43:42:1e:89:d8:84:cb:13:f1:d9: + bb:e1:89:60:b8:8c:28:56:ac:14:1d:9c:0a:e7:71: + eb:cf:0e:dd:3d:a9:96:a1:48:bd:3c:f7:af:b5:0d: + 22:4c:c0:11:81:ec:56:3b:f6:d3:a2:e2:5b:b7:b2: + 04:22:52:95:80:93:69:e8:8e:4c:65:f1:91:03:2d: + 70:74:02:ea:8b:67:15:29:69:52:02:bb:d7:df:50: + 6a:55:46:bf:a0:a3:28:61:7f:70:d0:c3:a2:aa:2c: + 21:aa:47:ce:28:9c:06:45:76:bf:82:18:27:b4:d5: + ae:b4:cb:50:e6:6b:f4:4c:86:71:30:e9:a6:df:16: + 86:e0:d8:ff:40:dd:fb:d0:42:88:7f:a3:33:3a:2e: + 5c:1e:41:11:81:63:ce:18:71:6b:2b:ec:a6:8a:b7: + 31:5c:3a:6a:47:e0:c3:79:59:d6:20:1a:af:f2:6a: + 98:aa:72:bc:57:4a:d2:4b:9d:bb:10:fc:b0:4c:41: + e5:ed:1d:3d:5e:28:9d:9c:cc:bf:b3:51:da:a7:47: + e5:84:53 + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Key Identifier: + BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4 + X509v3 Key Usage: critical + Certificate Sign, CRL Sign + X509v3 Basic Constraints: critical + CA:TRUE + Signature Algorithm: sha384WithRSAEncryption + 0a:f1:d5:46:84:b7:ae:51:bb:6c:b2:4d:41:14:00:93:4c:9c: + cb:e5:c0:54:cf:a0:25:8e:02:f9:fd:b0:a2:0d:f5:20:98:3c: + 13:2d:ac:56:a2:b0:d6:7e:11:92:e9:2e:ba:9e:2e:9a:72:b1: + bd:19:44:6c:61:35:a2:9a:b4:16:12:69:5a:8c:e1:d7:3e:a4: + 1a:e8:2f:03:f4:ae:61:1d:10:1b:2a:a4:8b:7a:c5:fe:05:a6: + e1:c0:d6:c8:fe:9e:ae:8f:2b:ba:3d:99:f8:d8:73:09:58:46: + 6e:a6:9c:f4:d7:27:d3:95:da:37:83:72:1c:d3:73:e0:a2:47: + 99:03:38:5d:d5:49:79:00:29:1c:c7:ec:9b:20:1c:07:24:69: + 57:78:b2:39:fc:3a:84:a0:b5:9c:7c:8d:bf:2e:93:62:27:b7: + 39:da:17:18:ae:bd:3c:09:68:ff:84:9b:3c:d5:d6:0b:03:e3: + 57:9e:14:f7:d1:eb:4f:c8:bd:87:23:b7:b6:49:43:79:85:5c: + ba:eb:92:0b:a1:c6:e8:68:a8:4c:16:b1:1a:99:0a:e8:53:2c: + 92:bb:a1:09:18:75:0c:65:a8:7b:cb:23:b7:1a:c2:28:85:c3: + 1b:ff:d0:2b:62:ef:a4:7b:09:91:98:67:8c:14:01:cd:68:06: + 6a:63:21:75:03:80:88:8a:6e:81:c6:85:f2:a9:a4:2d:e7:f4: + a5:24:10:47:83:ca:cd:f4:8d:79:58:b1:06:9b:e7:1a:2a:d9: + 9d:01:d7:94:7d:ed:03:4a:ca:f0:db:e8:a9:01:3e:f5:56:99: + c9:1e:8e:49:3d:bb:e5:09:b9:e0:4f:49:92:3d:16:82:40:cc: + cc:59:c6:e6:3a:ed:12:2e:69:3c:6c:95:b1:fd:aa:1d:7b:7f: + 86:be:1e:0e:32:46:fb:fb:13:8f:75:7f:4c:8b:4b:46:63:fe: + 00:34:40:70:c1:c3:b9:a1:dd:a6:70:e2:04:b3:41:bc:e9:80: + 91:ea:64:9c:7a:e1:22:03:a9:9c:6e:6f:0e:65:4f:6c:87:87: + 5e:f3:6e:a0:f9:75:a5:9b:40:e8:53:b2:27:9d:4a:b9:c0:77: + 21:8d:ff:87:f2:de:bc:8c:ef:17:df:b7:49:0b:d1:f2:6e:30: + 0b:1a:0e:4e:76:ed:11:fc:f5:e9:56:b2:7d:bf:c7:6d:0a:93: + 8c:a5:d0:c0:b6:1d:be:3a:4e:94:a2:d7:6e:6c:0b:c2:8a:7c: + fa:20:f3:c4:e4:e5:cd:0d:a8:cb:91:92:b1:7c:85:ec:b5:14: + 69:66:0e:82:e7:cd:ce:c8:2d:a6:51:7f:21:c1:35:53:85:06: + 4a:5d:9f:ad:bb:1b:5f:74 +SHA1 Fingerprint=AF:E5:D2:44:A8:D1:19:42:30:FF:47:9F:E2:F8:97:BB:CD:7A:8C:B4 diff --git a/luni/src/main/java/android/system/Os.java b/luni/src/main/java/android/system/Os.java index 0b80b52..9d6dc1b 100644 --- a/luni/src/main/java/android/system/Os.java +++ b/luni/src/main/java/android/system/Os.java @@ -16,20 +16,6 @@ package android.system; -import android.system.ErrnoException; -import android.system.GaiException; -import android.system.StructAddrinfo; -import android.system.StructFlock; -import android.system.StructGroupReq; -import android.system.StructGroupSourceReq; -import android.system.StructLinger; -import android.system.StructPasswd; -import android.system.StructPollfd; -import android.system.StructStat; -import android.system.StructStatVfs; -import android.system.StructTimeval; -import android.system.StructUcred; -import android.system.StructUtsname; import android.util.MutableInt; import android.util.MutableLong; import java.io.FileDescriptor; @@ -125,7 +111,7 @@ public final class Os { /** @hide */ public static int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return Libcore.os.fcntlVoid(fd, cmd); } /** @hide */ public static int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException { return Libcore.os.fcntlLong(fd, cmd, arg); } - /** @hide */ public static int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException { return Libcore.os.fcntlFlock(fd, cmd, arg); } + /** @hide */ public static int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException, InterruptedIOException { return Libcore.os.fcntlFlock(fd, cmd, arg); } /** * See <a href="http://man7.org/linux/man-pages/man2/fdatasync.2.html">fdatasync(2)</a>. diff --git a/luni/src/main/java/java/lang/System.java b/luni/src/main/java/java/lang/System.java index 55ca762..9425894 100644 --- a/luni/src/main/java/java/lang/System.java +++ b/luni/src/main/java/java/lang/System.java @@ -894,7 +894,7 @@ public final class System { /** * Sets the value of a particular system property. Most system properties - * are read only and cannot be cleared or modified. See {@link #setProperty} for a + * are read only and cannot be cleared or modified. See {@link #getProperty} for a * list of such properties. * * @return the old value of the property or {@code null} if the property @@ -907,7 +907,7 @@ public final class System { /** * Removes a specific system property. Most system properties - * are read only and cannot be cleared or modified. See {@link #setProperty} for a + * are read only and cannot be cleared or modified. See {@link #getProperty} for a * list of such properties. * * @return the property value or {@code null} if the property didn't exist. @@ -1069,7 +1069,7 @@ public final class System { /** * Attempts to set all system properties. Copies all properties from * {@code p} and discards system properties that are read only and cannot - * be modified. See {@link #setProperty} for a list of such properties. + * be modified. See {@link #getProperty} for a list of such properties. */ public static void setProperties(Properties p) { PropertiesWithNonOverrideableDefaults userProperties = diff --git a/luni/src/main/java/java/net/URI.java b/luni/src/main/java/java/net/URI.java index f206473..60bb5db 100644 --- a/luni/src/main/java/java/net/URI.java +++ b/luni/src/main/java/java/net/URI.java @@ -571,7 +571,10 @@ public final class URI implements Comparable<URI>, Serializable { private boolean isValidDomainName(String host) { try { - UriCodec.validateSimple(host, "-."); + // The RFCs don't permit underscores in hostnames, but URI has to because + // a certain large website doesn't seem to care about standards and specs. + // See bugs 18023709, 17579865 and 18016625. + UriCodec.validateSimple(host, "_-."); } catch (URISyntaxException e) { return false; } diff --git a/luni/src/main/java/java/nio/DatagramChannelImpl.java b/luni/src/main/java/java/nio/DatagramChannelImpl.java index 9008637..8dd6f29 100644 --- a/luni/src/main/java/java/nio/DatagramChannelImpl.java +++ b/luni/src/main/java/java/nio/DatagramChannelImpl.java @@ -274,15 +274,9 @@ class DatagramChannelImpl extends DatagramChannel implements FileDescriptorChann private SocketAddress receiveDirectImpl(ByteBuffer target, boolean loop) throws IOException { SocketAddress retAddr = null; DatagramPacket receivePacket = new DatagramPacket(EmptyArray.BYTE, 0); - int oldposition = target.position(); - int received; do { - received = IoBridge.recvfrom(false, fd, target, 0, receivePacket, isConnected()); + IoBridge.recvfrom(false, fd, target, 0, receivePacket, isConnected()); if (receivePacket.getAddress() != null) { - // copy the data of received packet - if (received > 0) { - target.position(oldposition + received); - } retAddr = receivePacket.getSocketAddress(); break; } @@ -309,11 +303,7 @@ class DatagramChannelImpl extends DatagramChannel implements FileDescriptorChann int sendCount = 0; try { begin(); - int oldPosition = source.position(); sendCount = IoBridge.sendto(fd, source, 0, isa.getAddress(), isa.getPort()); - if (sendCount > 0) { - source.position(oldPosition + sendCount); - } if (!isBound) { onBind(true /* updateSocketState */); } @@ -336,10 +326,6 @@ class DatagramChannelImpl extends DatagramChannel implements FileDescriptorChann int readCount; if (target.isDirect() || target.hasArray()) { readCount = readImpl(target); - if (readCount > 0) { - target.position(target.position() + readCount); - } - } else { byte[] readArray = new byte[target.remaining()]; ByteBuffer readBuffer = ByteBuffer.wrap(readArray); @@ -406,11 +392,7 @@ class DatagramChannelImpl extends DatagramChannel implements FileDescriptorChann return 0; } - int writeCount = writeImpl(src); - if (writeCount > 0) { - src.position(src.position() + writeCount); - } - return writeCount; + return writeImpl(src); } /** diff --git a/luni/src/main/java/java/nio/FileChannelImpl.java b/luni/src/main/java/java/nio/FileChannelImpl.java index d72b9f0..b560864 100644 --- a/luni/src/main/java/java/nio/FileChannelImpl.java +++ b/luni/src/main/java/java/nio/FileChannelImpl.java @@ -323,9 +323,7 @@ final class FileChannelImpl extends FileChannel { } finally { end(completed && bytesRead >= 0); } - if (bytesRead > 0) { - buffer.position(buffer.position() + bytesRead); - } + return bytesRead; } @@ -508,9 +506,6 @@ final class FileChannelImpl extends FileChannel { } finally { end(completed); } - if (bytesWritten > 0) { - buffer.position(buffer.position() + bytesWritten); - } return bytesWritten; } diff --git a/luni/src/main/java/java/nio/SocketChannelImpl.java b/luni/src/main/java/java/nio/SocketChannelImpl.java index d5cb716..d09aaef 100644 --- a/luni/src/main/java/java/nio/SocketChannelImpl.java +++ b/luni/src/main/java/java/nio/SocketChannelImpl.java @@ -340,9 +340,6 @@ class SocketChannelImpl extends SocketChannel implements FileDescriptorChannel { begin(); } readCount = IoBridge.recvfrom(true, fd, dst, 0, null, false); - if (readCount > 0) { - dst.position(dst.position() + readCount); - } } finally { if (isBlocking()) { end(readCount > 0); @@ -404,9 +401,6 @@ class SocketChannelImpl extends SocketChannel implements FileDescriptorChannel { begin(); } writeCount = IoBridge.sendto(fd, src, 0, null, 0); - if (writeCount > 0) { - src.position(src.position() + writeCount); - } } finally { if (isBlocking()) { end(writeCount >= 0); diff --git a/luni/src/main/java/java/text/DateFormat.java b/luni/src/main/java/java/text/DateFormat.java index 3055843..ebdf73a 100644 --- a/luni/src/main/java/java/text/DateFormat.java +++ b/luni/src/main/java/java/text/DateFormat.java @@ -66,6 +66,13 @@ public abstract class DateFormat extends Format { private static final long serialVersionUID = 7218322306649953788L; /** + * A tri-state boolean. If we're running stand-alone this will be null. + * If we're running in an app, the frameworks will have told us the user preference. + * @hide + */ + public static Boolean is24Hour; + + /** * The calendar that this {@code DateFormat} uses to format a number * representing a date. */ @@ -466,6 +473,7 @@ public abstract class DateFormat extends Format { * @hide for internal use only. */ public static final void set24HourTimePref(boolean is24Hour) { + DateFormat.is24Hour = is24Hour; } /** diff --git a/luni/src/main/java/java/text/DecimalFormatSymbols.java b/luni/src/main/java/java/text/DecimalFormatSymbols.java index fba2d6e..2f1d4f4 100644 --- a/luni/src/main/java/java/text/DecimalFormatSymbols.java +++ b/luni/src/main/java/java/text/DecimalFormatSymbols.java @@ -47,7 +47,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { private char decimalSeparator; private char groupingSeparator; private char patternSeparator; - private char percent; + private String percent; private char perMill; private char monetarySeparator; private String minusSign; @@ -189,7 +189,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { NaN.equals(obj.NaN) && patternSeparator == obj.patternSeparator && perMill == obj.perMill && - percent == obj.percent && + percent.equals(obj.percent) && zeroDigit == obj.zeroDigit; } @@ -306,6 +306,11 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { return minusSign; } + /** @hide */ + public String getPercentString() { + return percent; + } + /** * Returns the character which represents the decimal point in a monetary * value. @@ -341,7 +346,10 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { * @return the percent character. */ public char getPercent() { - return percent; + if (percent.length() == 1) { + return percent.charAt(0); + } + throw new UnsupportedOperationException("Percent spans multiple characters: " + percent); } /** @@ -378,7 +386,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { result = 31*result + decimalSeparator; result = 31*result + groupingSeparator; result = 31*result + patternSeparator; - result = 31*result + percent; + result = 31*result + percent.hashCode(); result = 31*result + perMill; result = 31*result + monetarySeparator; result = 31*result + minusSign.hashCode(); @@ -406,9 +414,6 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { if (currency == null) { throw new NullPointerException("currency == null"); } - if (currency == this.currency) { - return; - } this.currency = currency; intlCurrencySymbol = currency.getCurrencyCode(); currencySymbol = currency.getSymbol(locale); @@ -544,7 +549,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { * the percent character. */ public void setPercent(char value) { - this.percent = value; + this.percent = String.valueOf(value); } /** diff --git a/luni/src/main/java/java/util/Timer.java b/luni/src/main/java/java/util/Timer.java index 7192f9b..6a3b305 100644 --- a/luni/src/main/java/java/util/Timer.java +++ b/luni/src/main/java/java/util/Timer.java @@ -25,7 +25,7 @@ package java.util; * <p>Each timer has one thread on which tasks are executed sequentially. When * this thread is busy running a task, runnable tasks may be subject to delays. * - * <p>One-shot are scheduled to run at an absolute time or after a relative + * <p>One-shot tasks are scheduled to run at an absolute time or after a relative * delay. * * <p>Recurring tasks are scheduled with either a fixed period or a fixed rate: diff --git a/luni/src/main/java/libcore/icu/LocaleData.java b/luni/src/main/java/libcore/icu/LocaleData.java index 9e07244..cca38e1 100644 --- a/luni/src/main/java/libcore/icu/LocaleData.java +++ b/luni/src/main/java/libcore/icu/LocaleData.java @@ -87,6 +87,12 @@ public final class LocaleData { // Used by android.text.format.DateFormat.getDateFormatStringForSetting. public String shortDateFormat4; + // Used by DateFormat to implement 12- and 24-hour SHORT and MEDIUM. + public String timeFormat_hm; + public String timeFormat_Hm; + public String timeFormat_hms; + public String timeFormat_Hms; + // Used by android.text.format.DateFormat.getTimeFormat. public String timeFormat12; // "hh:mm a" public String timeFormat24; // "HH:mm" @@ -96,7 +102,7 @@ public final class LocaleData { public char decimalSeparator; public char groupingSeparator; public char patternSeparator; - public char percent; + public String percent; public char perMill; public char monetarySeparator; public String minusSign; @@ -175,12 +181,22 @@ public final class LocaleData { public String getTimeFormat(int style) { switch (style) { case DateFormat.SHORT: - return shortTimeFormat; + if (DateFormat.is24Hour == null) { + return shortTimeFormat; + } else { + return DateFormat.is24Hour ? timeFormat_Hm : timeFormat_hm; + } case DateFormat.MEDIUM: - return mediumTimeFormat; + if (DateFormat.is24Hour == null) { + return mediumTimeFormat; + } else { + return DateFormat.is24Hour ? timeFormat_Hms : timeFormat_hms; + } case DateFormat.LONG: + // CLDR doesn't really have anything we can use to obey the 12-/24-hour preference. return longTimeFormat; case DateFormat.FULL: + // CLDR doesn't really have anything we can use to obey the 12-/24-hour preference. return fullTimeFormat; } throw new AssertionError(); @@ -192,9 +208,17 @@ public final class LocaleData { throw new AssertionError("couldn't initialize LocaleData for locale " + locale); } - // Get the "h:mm a" and "HH:mm" 12- and 24-hour time format strings. - localeData.timeFormat12 = ICU.getBestDateTimePattern("hm", locale); - localeData.timeFormat24 = ICU.getBestDateTimePattern("Hm", locale); + // Get the SHORT and MEDIUM 12- and 24-hour time format strings. + localeData.timeFormat_hm = ICU.getBestDateTimePattern("hm", locale); + localeData.timeFormat_Hm = ICU.getBestDateTimePattern("Hm", locale); + localeData.timeFormat_hms = ICU.getBestDateTimePattern("hms", locale); + localeData.timeFormat_Hms = ICU.getBestDateTimePattern("Hms", locale); + // We could move callers over to the other fields, but these seem simpler and discourage + // people from shooting themselves in the foot by learning about patterns and skeletons. + // TODO: the right fix here is probably to move callers over to java.text.DateFormat, + // so nothing outside libcore references these any more. + localeData.timeFormat12 = localeData.timeFormat_hm; + localeData.timeFormat24 = localeData.timeFormat_Hm; // Fix up a couple of patterns. if (localeData.fullTimeFormat != null) { diff --git a/luni/src/main/java/libcore/icu/NativeDecimalFormat.java b/luni/src/main/java/libcore/icu/NativeDecimalFormat.java index fd179c1..cf11ac7 100644 --- a/luni/src/main/java/libcore/icu/NativeDecimalFormat.java +++ b/luni/src/main/java/libcore/icu/NativeDecimalFormat.java @@ -158,7 +158,7 @@ public final class NativeDecimalFormat implements Cloneable { dfs.getGroupingSeparator(), dfs.getInfinity(), dfs.getInternationalCurrencySymbol(), dfs.getMinusSignString(), dfs.getMonetaryDecimalSeparator(), dfs.getNaN(), dfs.getPatternSeparator(), - dfs.getPercent(), dfs.getPerMill(), dfs.getZeroDigit()); + dfs.getPercentString(), dfs.getPerMill(), dfs.getZeroDigit()); this.lastPattern = pattern; } catch (NullPointerException npe) { throw npe; @@ -269,7 +269,7 @@ public final class NativeDecimalFormat implements Cloneable { dfs.getDigit(), dfs.getExponentSeparator(), dfs.getGroupingSeparator(), dfs.getInfinity(), dfs.getInternationalCurrencySymbol(), dfs.getMinusSignString(), dfs.getMonetaryDecimalSeparator(), dfs.getNaN(), dfs.getPatternSeparator(), - dfs.getPercent(), dfs.getPerMill(), dfs.getZeroDigit()); + dfs.getPercentString(), dfs.getPerMill(), dfs.getZeroDigit()); } public void setDecimalFormatSymbols(final LocaleData localeData) { @@ -626,13 +626,13 @@ public final class NativeDecimalFormat implements Cloneable { private static native long open(String pattern, String currencySymbol, char decimalSeparator, char digit, String exponentSeparator, char groupingSeparator, String infinity, String internationalCurrencySymbol, String minusSign, - char monetaryDecimalSeparator, String nan, char patternSeparator, char percent, + char monetaryDecimalSeparator, String nan, char patternSeparator, String percent, char perMill, char zeroDigit); private static native Number parse(long addr, String string, ParsePosition position, boolean parseBigDecimal); private static native void setDecimalFormatSymbols(long addr, String currencySymbol, char decimalSeparator, char digit, String exponentSeparator, char groupingSeparator, String infinity, String internationalCurrencySymbol, String minusSign, - char monetaryDecimalSeparator, String nan, char patternSeparator, char percent, + char monetaryDecimalSeparator, String nan, char patternSeparator, String percent, char perMill, char zeroDigit); private static native void setSymbol(long addr, int symbol, String str); private static native void setAttribute(long addr, int symbol, int i); diff --git a/luni/src/main/java/libcore/icu/NativePluralRules.java b/luni/src/main/java/libcore/icu/NativePluralRules.java index dbcf089..f9fe74b 100644 --- a/luni/src/main/java/libcore/icu/NativePluralRules.java +++ b/luni/src/main/java/libcore/icu/NativePluralRules.java @@ -55,6 +55,10 @@ public final class NativePluralRules { * to the first rule that matches the given value. */ public int quantityForInt(int value) { + // Pre-L compatibility. http://b/18429565. + if (value < 0) { + return OTHER; + } return quantityForIntImpl(address, value); } diff --git a/luni/src/main/java/libcore/io/ForwardingOs.java b/luni/src/main/java/libcore/io/ForwardingOs.java index bf4b448..584fd58 100644 --- a/luni/src/main/java/libcore/io/ForwardingOs.java +++ b/luni/src/main/java/libcore/io/ForwardingOs.java @@ -67,7 +67,7 @@ public class ForwardingOs implements Os { public void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException { os.fchown(fd, uid, gid); } public int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return os.fcntlVoid(fd, cmd); } public int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException { return os.fcntlLong(fd, cmd, arg); } - public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException { return os.fcntlFlock(fd, cmd, arg); } + public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException, InterruptedIOException { return os.fcntlFlock(fd, cmd, arg); } public void fdatasync(FileDescriptor fd) throws ErrnoException { os.fdatasync(fd); } public StructStat fstat(FileDescriptor fd) throws ErrnoException { return os.fstat(fd); } public StructStatVfs fstatvfs(FileDescriptor fd) throws ErrnoException { return os.fstatvfs(fd); } diff --git a/luni/src/main/java/libcore/io/Os.java b/luni/src/main/java/libcore/io/Os.java index 511bb27..9f080a6 100644 --- a/luni/src/main/java/libcore/io/Os.java +++ b/luni/src/main/java/libcore/io/Os.java @@ -58,7 +58,7 @@ public interface Os { public void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException; public int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException; public int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException; - public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException; + public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException, InterruptedIOException; public void fdatasync(FileDescriptor fd) throws ErrnoException; public StructStat fstat(FileDescriptor fd) throws ErrnoException; public StructStatVfs fstatvfs(FileDescriptor fd) throws ErrnoException; diff --git a/luni/src/main/java/libcore/io/Posix.java b/luni/src/main/java/libcore/io/Posix.java index f5eaaa3..5bd1b06 100644 --- a/luni/src/main/java/libcore/io/Posix.java +++ b/luni/src/main/java/libcore/io/Posix.java @@ -61,7 +61,7 @@ public final class Posix implements Os { public native void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException; public native int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException; public native int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException; - public native int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException; + public native int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException, InterruptedIOException; public native void fdatasync(FileDescriptor fd) throws ErrnoException; public native StructStat fstat(FileDescriptor fd) throws ErrnoException; public native StructStatVfs fstatvfs(FileDescriptor fd) throws ErrnoException; @@ -112,11 +112,17 @@ public final class Posix implements Os { public native void posix_fallocate(FileDescriptor fd, long offset, long length) throws ErrnoException; public native int prctl(int option, long arg2, long arg3, long arg4, long arg5) throws ErrnoException; public int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { + final int bytesRead; + final int position = buffer.position(); + if (buffer.isDirect()) { - return preadBytes(fd, buffer, buffer.position(), buffer.remaining(), offset); + bytesRead = preadBytes(fd, buffer, position, buffer.remaining(), offset); } else { - return preadBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + buffer.position(), buffer.remaining(), offset); + bytesRead = preadBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), offset); } + + maybeUpdateBufferPosition(buffer, position, bytesRead); + return bytesRead; } public int pread(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException { // This indirection isn't strictly necessary, but ensures that our public interface is type safe. @@ -124,11 +130,17 @@ public final class Posix implements Os { } private native int preadBytes(FileDescriptor fd, Object buffer, int bufferOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException; public int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { + final int bytesWritten; + final int position = buffer.position(); + if (buffer.isDirect()) { - return pwriteBytes(fd, buffer, buffer.position(), buffer.remaining(), offset); + bytesWritten = pwriteBytes(fd, buffer, position, buffer.remaining(), offset); } else { - return pwriteBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + buffer.position(), buffer.remaining(), offset); + bytesWritten = pwriteBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), offset); } + + maybeUpdateBufferPosition(buffer, position, bytesWritten); + return bytesWritten; } public int pwrite(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException { // This indirection isn't strictly necessary, but ensures that our public interface is type safe. @@ -136,11 +148,17 @@ public final class Posix implements Os { } private native int pwriteBytes(FileDescriptor fd, Object buffer, int bufferOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException; public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { + final int bytesRead; + final int position = buffer.position(); + if (buffer.isDirect()) { - return readBytes(fd, buffer, buffer.position(), buffer.remaining()); + bytesRead = readBytes(fd, buffer, position, buffer.remaining()); } else { - return readBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + buffer.position(), buffer.remaining()); + bytesRead = readBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining()); } + + maybeUpdateBufferPosition(buffer, position, bytesRead); + return bytesRead; } public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { // This indirection isn't strictly necessary, but ensures that our public interface is type safe. @@ -150,11 +168,17 @@ public final class Posix implements Os { public native String readlink(String path) throws ErrnoException; public native int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException; public int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { + final int bytesReceived; + final int position = buffer.position(); + if (buffer.isDirect()) { - return recvfromBytes(fd, buffer, buffer.position(), buffer.remaining(), flags, srcAddress); + bytesReceived = recvfromBytes(fd, buffer, position, buffer.remaining(), flags, srcAddress); } else { - return recvfromBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + buffer.position(), buffer.remaining(), flags, srcAddress); + bytesReceived = recvfromBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), flags, srcAddress); } + + maybeUpdateBufferPosition(buffer, position, bytesReceived); + return bytesReceived; } public int recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { // This indirection isn't strictly necessary, but ensures that our public interface is type safe. @@ -165,11 +189,17 @@ public final class Posix implements Os { public native void rename(String oldPath, String newPath) throws ErrnoException; public native long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException; public int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { + final int bytesSent; + final int position = buffer.position(); + if (buffer.isDirect()) { - return sendtoBytes(fd, buffer, buffer.position(), buffer.remaining(), flags, inetAddress, port); + bytesSent = sendtoBytes(fd, buffer, position, buffer.remaining(), flags, inetAddress, port); } else { - return sendtoBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + buffer.position(), buffer.remaining(), flags, inetAddress, port); + bytesSent = sendtoBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), flags, inetAddress, port); } + + maybeUpdateBufferPosition(buffer, position, bytesSent); + return bytesSent; } public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { // This indirection isn't strictly necessary, but ensures that our public interface is type safe. @@ -212,11 +242,16 @@ public final class Posix implements Os { public native void unsetenv(String name) throws ErrnoException; public native int waitpid(int pid, MutableInt status, int options) throws ErrnoException; public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { + final int bytesWritten; + final int position = buffer.position(); if (buffer.isDirect()) { - return writeBytes(fd, buffer, buffer.position(), buffer.remaining()); + bytesWritten = writeBytes(fd, buffer, position, buffer.remaining()); } else { - return writeBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + buffer.position(), buffer.remaining()); + bytesWritten = writeBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining()); } + + maybeUpdateBufferPosition(buffer, position, bytesWritten); + return bytesWritten; } public int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { // This indirection isn't strictly necessary, but ensures that our public interface is type safe. @@ -224,4 +259,10 @@ public final class Posix implements Os { } private native int writeBytes(FileDescriptor fd, Object buffer, int offset, int byteCount) throws ErrnoException, InterruptedIOException; public native int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException; + + private static void maybeUpdateBufferPosition(ByteBuffer buffer, int originalPosition, int bytesReadOrWritten) { + if (bytesReadOrWritten > 0) { + buffer.position(bytesReadOrWritten + originalPosition); + } + } } diff --git a/luni/src/main/java/libcore/net/MimeUtils.java b/luni/src/main/java/libcore/net/MimeUtils.java index a5a1469..125ea87 100644 --- a/luni/src/main/java/libcore/net/MimeUtils.java +++ b/luni/src/main/java/libcore/net/MimeUtils.java @@ -259,8 +259,9 @@ public final class MimeUtils { add("image/ico", "cur"); add("image/ico", "ico"); add("image/ief", "ief"); - add("image/jpeg", "jpeg"); + // add ".jpg" first so it will be the default for guessExtensionFromMimeType add("image/jpeg", "jpg"); + add("image/jpeg", "jpeg"); add("image/jpeg", "jpe"); add("image/pcx", "pcx"); add("image/png", "png"); diff --git a/luni/src/main/java/libcore/util/ZoneInfoDB.java b/luni/src/main/java/libcore/util/ZoneInfoDB.java index a9d06a4..906ec14 100644 --- a/luni/src/main/java/libcore/util/ZoneInfoDB.java +++ b/luni/src/main/java/libcore/util/ZoneInfoDB.java @@ -41,8 +41,7 @@ import libcore.io.MemoryMappedFile; */ public final class ZoneInfoDB { private static final TzData DATA = - new TzData(System.getenv("ANDROID_DATA") + "/misc/zoneinfo/tzdata", - System.getenv("ANDROID_ROOT") + "/usr/share/zoneinfo/tzdata"); + new TzData(System.getenv("ANDROID_ROOT") + "/usr/share/zoneinfo/tzdata"); public static class TzData { /** diff --git a/luni/src/main/java/org/apache/harmony/security/utils/JarUtils.java b/luni/src/main/java/org/apache/harmony/security/utils/JarUtils.java index e7f3596..917a3a8 100644 --- a/luni/src/main/java/org/apache/harmony/security/utils/JarUtils.java +++ b/luni/src/main/java/org/apache/harmony/security/utils/JarUtils.java @@ -124,20 +124,21 @@ public class JarUtils { final String daOid = sigInfo.getDigestAlgorithm(); final String daName = sigInfo.getDigestAlgorithmName(); final String deaOid = sigInfo.getDigestEncryptionAlgorithm(); + final String deaName = sigInfo.getDigestEncryptionAlgorithmName(); String alg = null; Signature sig = null; - if (deaOid != null) { - alg = deaOid; + if (daOid != null && deaOid != null) { + alg = daOid + "with" + deaOid; try { sig = Signature.getInstance(alg); } catch (NoSuchAlgorithmException e) { } - final String deaName = sigInfo.getDigestEncryptionAlgorithmName(); - if (sig == null && deaName != null) { - alg = deaName; + // Try to convert to names instead of OID. + if (sig == null && daName != null && deaName != null) { + alg = daName + "with" + deaName; try { sig = Signature.getInstance(alg); } catch (NoSuchAlgorithmException e) { @@ -145,17 +146,15 @@ public class JarUtils { } } - if (sig == null && daOid != null && deaOid != null) { - alg = daOid + "with" + deaOid; + if (sig == null && deaOid != null) { + alg = deaOid; try { sig = Signature.getInstance(alg); } catch (NoSuchAlgorithmException e) { } - // Try to convert to names instead of OID. if (sig == null) { - final String deaName = sigInfo.getDigestEncryptionAlgorithmName(); - alg = daName + "with" + deaName; + alg = deaName; try { sig = Signature.getInstance(alg); } catch (NoSuchAlgorithmException e) { @@ -250,6 +249,10 @@ public class JarUtils { } chain.add(issuerCert); count++; + /* Prevent growing infinitely if there is a loop */ + if (count > candidates.length) { + break; + } issuer = issuerCert.getIssuerDN(); if (issuerCert.getSubjectDN().equals(issuer)) { break; diff --git a/luni/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java b/luni/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java index d1079c8..040a012 100644 --- a/luni/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java +++ b/luni/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java @@ -416,11 +416,13 @@ class DocumentBuilderImpl extends DocumentBuilder { private String resolveCharacterReference(String value, int base) { try { - int ch = Integer.parseInt(value, base); - if (ch < 0 || ch > Character.MAX_VALUE) { - return null; + int codePoint = Integer.parseInt(value, base); + if (Character.isBmpCodePoint(codePoint)) { + return String.valueOf((char) codePoint); + } else { + char[] surrogatePair = Character.toChars(codePoint); + return new String(surrogatePair); } - return String.valueOf((char) ch); } catch (NumberFormatException ex) { return null; } diff --git a/luni/src/main/native/java_io_FileDescriptor.cpp b/luni/src/main/native/java_io_FileDescriptor.cpp index fe7e07e..2a7820f 100644 --- a/luni/src/main/native/java_io_FileDescriptor.cpp +++ b/luni/src/main/native/java_io_FileDescriptor.cpp @@ -22,9 +22,11 @@ #include <sys/types.h> static jboolean FileDescriptor_isSocket(JNIEnv*, jclass, jint fd) { - int error; - socklen_t error_length = sizeof(error); - return TEMP_FAILURE_RETRY(getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &error_length)); + // If getsockopt succeeds, we know we're dealing with a socket. + // This is the cheapest way we know of to test whether an fd is a socket. + int option; + socklen_t option_length = sizeof(option); + return TEMP_FAILURE_RETRY(getsockopt(fd, SOL_SOCKET, SO_DEBUG, &option, &option_length)) == 0; } static JNINativeMethod gMethods[] = { diff --git a/luni/src/main/native/java_util_jar_StrictJarFile.cpp b/luni/src/main/native/java_util_jar_StrictJarFile.cpp index 7611749..efcc74c 100644 --- a/luni/src/main/native/java_util_jar_StrictJarFile.cpp +++ b/luni/src/main/native/java_util_jar_StrictJarFile.cpp @@ -32,7 +32,28 @@ static void throwIoException(JNIEnv* env, const int32_t errorCode) { jniThrowException(env, "java/io/IOException", ErrorCodeString(errorCode)); } -static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, jstring entryName, +// Constructs a string out of |name| with the default charset (UTF-8 on android). +// We prefer this to JNI's NewStringUTF because the string constructor will +// replace unmappable and malformed bytes instead of throwing. See b/18584205 +// +// Returns |NULL| iff. we couldn't allocate the string object or its constructor +// arguments. +// +// TODO: switch back to NewStringUTF after libziparchive is modified to reject +// files whose names aren't valid UTF-8. +static jobject constructString(JNIEnv* env, const char* name, const uint16_t nameLength) { + jbyteArray javaNameBytes = env->NewByteArray(nameLength); + if (javaNameBytes == NULL) { + return NULL; + } + env->SetByteArrayRegion(javaNameBytes, 0, nameLength, reinterpret_cast<const jbyte*>(name)); + + ScopedLocalRef<jclass> stringClass(env, env->FindClass("java/lang/String")); + const jmethodID stringCtor = env->GetMethodID(stringClass.get(), "<init>", "([B)V"); + return env->NewObject(stringClass.get(), stringCtor, javaNameBytes); +} + +static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, const jobject entryName, const uint16_t nameLength) { ScopedLocalRef<jclass> zipEntryClass(env, env->FindClass("java/util/zip/ZipEntry")); const jmethodID zipEntryCtor = env->GetMethodID(zipEntryClass.get(), "<init>", @@ -54,6 +75,11 @@ static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, jstring entryName static_cast<jlong>(entry.offset)); } +static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, const char* name, + const uint16_t nameLength) { + return newZipEntry(env, entry, constructString(env, name, nameLength), nameLength); +} + static jlong StrictJarFile_nativeOpenJarFile(JNIEnv* env, jobject, jstring fileName) { ScopedUtfChars fileChars(env, fileName); if (fileChars.c_str() == NULL) { @@ -133,9 +159,8 @@ static jobject StrictJarFile_nativeNextEntry(JNIEnv* env, jobject, jlong iterati UniquePtr<char[]> entryNameCString(new char[entryName.name_length + 1]); memcpy(entryNameCString.get(), entryName.name, entryName.name_length); entryNameCString[entryName.name_length] = '\0'; - ScopedLocalRef<jstring> entryNameString(env, env->NewStringUTF(entryNameCString.get())); - return newZipEntry(env, data, entryNameString.get(), entryName.name_length); + return newZipEntry(env, data, entryNameCString.get(), entryName.name_length); } static jobject StrictJarFile_nativeFindEntry(JNIEnv* env, jobject, jlong nativeHandle, @@ -169,5 +194,4 @@ static JNINativeMethod gMethods[] = { void register_java_util_jar_StrictJarFile(JNIEnv* env) { jniRegisterNativeMethods(env, "java/util/jar/StrictJarFile", gMethods, NELEM(gMethods)); - } diff --git a/luni/src/main/native/libcore_icu_ICU.cpp b/luni/src/main/native/libcore_icu_ICU.cpp index 1528a2d..d27b11d 100644 --- a/luni/src/main/native/libcore_icu_ICU.cpp +++ b/luni/src/main/native/libcore_icu_ICU.cpp @@ -406,7 +406,7 @@ static void setDecimalFormatSymbolsData(JNIEnv* env, jobject obj, Locale& locale setCharField(env, obj, "decimalSeparator", dfs.getSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol)); setCharField(env, obj, "groupingSeparator", dfs.getSymbol(DecimalFormatSymbols::kGroupingSeparatorSymbol)); setCharField(env, obj, "patternSeparator", dfs.getSymbol(DecimalFormatSymbols::kPatternSeparatorSymbol)); - setCharField(env, obj, "percent", dfs.getSymbol(DecimalFormatSymbols::kPercentSymbol)); + setStringField(env, obj, "percent", dfs.getSymbol(DecimalFormatSymbols::kPercentSymbol)); setCharField(env, obj, "perMill", dfs.getSymbol(DecimalFormatSymbols::kPerMillSymbol)); setCharField(env, obj, "monetarySeparator", dfs.getSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol)); setStringField(env, obj, "minusSign", dfs.getSymbol(DecimalFormatSymbols:: kMinusSignSymbol)); diff --git a/luni/src/main/native/libcore_icu_NativeDecimalFormat.cpp b/luni/src/main/native/libcore_icu_NativeDecimalFormat.cpp index c0fd42b..8e440e9 100644 --- a/luni/src/main/native/libcore_icu_NativeDecimalFormat.cpp +++ b/luni/src/main/native/libcore_icu_NativeDecimalFormat.cpp @@ -52,13 +52,14 @@ static DecimalFormatSymbols* makeDecimalFormatSymbols(JNIEnv* env, jchar groupingSeparator0, jstring infinity0, jstring internationalCurrencySymbol0, jstring minusSign0, jchar monetaryDecimalSeparator, jstring nan0, jchar patternSeparator, - jchar percent, jchar perMill, jchar zeroDigit) { + jstring percent0, jchar perMill, jchar zeroDigit) { ScopedJavaUnicodeString currencySymbol(env, currencySymbol0); ScopedJavaUnicodeString exponentSeparator(env, exponentSeparator0); ScopedJavaUnicodeString infinity(env, infinity0); ScopedJavaUnicodeString internationalCurrencySymbol(env, internationalCurrencySymbol0); ScopedJavaUnicodeString nan(env, nan0); ScopedJavaUnicodeString minusSign(env, minusSign0); + ScopedJavaUnicodeString percent(env, percent0); UnicodeString groupingSeparator(groupingSeparator0); DecimalFormatSymbols* result = new DecimalFormatSymbols; @@ -74,7 +75,7 @@ static DecimalFormatSymbols* makeDecimalFormatSymbols(JNIEnv* env, result->setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol, UnicodeString(monetaryDecimalSeparator)); result->setSymbol(DecimalFormatSymbols::kNaNSymbol, nan.unicodeString()); result->setSymbol(DecimalFormatSymbols::kPatternSeparatorSymbol, UnicodeString(patternSeparator)); - result->setSymbol(DecimalFormatSymbols::kPercentSymbol, UnicodeString(percent)); + result->setSymbol(DecimalFormatSymbols::kPercentSymbol, percent.unicodeString()); result->setSymbol(DecimalFormatSymbols::kPerMillSymbol, UnicodeString(perMill)); // java.text.DecimalFormatSymbols just uses a zero digit, // but ICU >= 4.6 has a field for each decimal digit. @@ -96,7 +97,7 @@ static void NativeDecimalFormat_setDecimalFormatSymbols(JNIEnv* env, jclass, jlo jchar groupingSeparator, jstring infinity, jstring internationalCurrencySymbol, jstring minusSign, jchar monetaryDecimalSeparator, jstring nan, jchar patternSeparator, - jchar percent, jchar perMill, jchar zeroDigit) { + jstring percent, jchar perMill, jchar zeroDigit) { DecimalFormatSymbols* symbols = makeDecimalFormatSymbols(env, currencySymbol, decimalSeparator, digit, exponentSeparator, groupingSeparator, infinity, internationalCurrencySymbol, minusSign, @@ -110,7 +111,7 @@ static jlong NativeDecimalFormat_open(JNIEnv* env, jclass, jstring pattern0, jchar groupingSeparator, jstring infinity, jstring internationalCurrencySymbol, jstring minusSign, jchar monetaryDecimalSeparator, jstring nan, jchar patternSeparator, - jchar percent, jchar perMill, jchar zeroDigit) { + jstring percent, jchar perMill, jchar zeroDigit) { UErrorCode status = U_ZERO_ERROR; UParseError parseError; ScopedJavaUnicodeString pattern(env, pattern0); @@ -368,10 +369,10 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(NativeDecimalFormat, formatDigitList, "(JLjava/lang/String;Llibcore/icu/NativeDecimalFormat$FieldPositionIterator;)[C"), NATIVE_METHOD(NativeDecimalFormat, getAttribute, "(JI)I"), NATIVE_METHOD(NativeDecimalFormat, getTextAttribute, "(JI)Ljava/lang/String;"), - NATIVE_METHOD(NativeDecimalFormat, open, "(Ljava/lang/String;Ljava/lang/String;CCLjava/lang/String;CLjava/lang/String;Ljava/lang/String;Ljava/lang/String;CLjava/lang/String;CCCC)J"), + NATIVE_METHOD(NativeDecimalFormat, open, "(Ljava/lang/String;Ljava/lang/String;CCLjava/lang/String;CLjava/lang/String;Ljava/lang/String;Ljava/lang/String;CLjava/lang/String;CLjava/lang/String;CC)J"), NATIVE_METHOD(NativeDecimalFormat, parse, "(JLjava/lang/String;Ljava/text/ParsePosition;Z)Ljava/lang/Number;"), NATIVE_METHOD(NativeDecimalFormat, setAttribute, "(JII)V"), - NATIVE_METHOD(NativeDecimalFormat, setDecimalFormatSymbols, "(JLjava/lang/String;CCLjava/lang/String;CLjava/lang/String;Ljava/lang/String;Ljava/lang/String;CLjava/lang/String;CCCC)V"), + NATIVE_METHOD(NativeDecimalFormat, setDecimalFormatSymbols, "(JLjava/lang/String;CCLjava/lang/String;CLjava/lang/String;Ljava/lang/String;Ljava/lang/String;CLjava/lang/String;CLjava/lang/String;CC)V"), NATIVE_METHOD(NativeDecimalFormat, setRoundingMode, "(JID)V"), NATIVE_METHOD(NativeDecimalFormat, setSymbol, "(JILjava/lang/String;)V"), NATIVE_METHOD(NativeDecimalFormat, setTextAttribute, "(JILjava/lang/String;)V"), diff --git a/luni/src/main/native/libcore_io_Posix.cpp b/luni/src/main/native/libcore_io_Posix.cpp index e8e8efb..7e9b22e 100644 --- a/luni/src/main/native/libcore_io_Posix.cpp +++ b/luni/src/main/native/libcore_io_Posix.cpp @@ -127,32 +127,27 @@ struct addrinfo_deleter { */ #define IO_FAILURE_RETRY(jni_env, return_type, syscall_name, java_fd, ...) ({ \ return_type _rc = -1; \ - int _fd = jniGetFDFromFileDescriptor(jni_env, java_fd); \ - if (_fd == -1) { \ - jniThrowException(jni_env, "java/io/IOException", "File descriptor closed"); \ - } else { \ - do { \ - bool _wasSignaled; \ - int _syscallErrno; \ - { \ - int _fd = jniGetFDFromFileDescriptor(jni_env, java_fd); \ - AsynchronousCloseMonitor _monitor(_fd); \ - _rc = syscall_name(_fd, __VA_ARGS__); \ - _syscallErrno = errno; \ - _wasSignaled = _monitor.wasSignaled(); \ - } \ - if (_wasSignaled) { \ - jniThrowException(jni_env, "java/io/InterruptedIOException", # syscall_name " interrupted"); \ - _rc = -1; \ - break; \ - } \ - if (_rc == -1 && _syscallErrno != EINTR) { \ - /* TODO: with a format string we could show the arguments too, like strace(1). */ \ - throwErrnoException(jni_env, # syscall_name); \ - break; \ - } \ - } while (_rc == -1); /* && _syscallErrno == EINTR && !_wasSignaled */ \ - } \ + do { \ + bool _wasSignaled; \ + int _syscallErrno; \ + { \ + int _fd = jniGetFDFromFileDescriptor(jni_env, java_fd); \ + AsynchronousCloseMonitor _monitor(_fd); \ + _rc = syscall_name(_fd, __VA_ARGS__); \ + _syscallErrno = errno; \ + _wasSignaled = _monitor.wasSignaled(); \ + } \ + if (_wasSignaled) { \ + jniThrowException(jni_env, "java/io/InterruptedIOException", # syscall_name " interrupted"); \ + _rc = -1; \ + break; \ + } \ + if (_rc == -1 && _syscallErrno != EINTR) { \ + /* TODO: with a format string we could show the arguments too, like strace(1). */ \ + throwErrnoException(jni_env, # syscall_name); \ + break; \ + } \ + } while (_rc == -1); /* && _syscallErrno == EINTR && !_wasSignaled */ \ _rc; }) static void throwException(JNIEnv* env, jclass exceptionClass, jmethodID ctor3, jmethodID ctor2, diff --git a/luni/src/test/java/com/android/org/bouncycastle/jce/provider/CertBlacklistTest.java b/luni/src/test/java/com/android/org/bouncycastle/jce/provider/CertBlacklistTest.java index 1475a63..8627225 100644 --- a/luni/src/test/java/com/android/org/bouncycastle/jce/provider/CertBlacklistTest.java +++ b/luni/src/test/java/com/android/org/bouncycastle/jce/provider/CertBlacklistTest.java @@ -151,7 +151,7 @@ public class CertBlacklistTest extends TestCase { private Set<String> getPubkeyBlacklist(String path) throws IOException { // set our blacklist path - CertBlacklist bl = new CertBlacklist(path, CertBlacklist.DEFAULT_SERIAL_BLACKLIST_PATH); + CertBlacklist bl = new CertBlacklist(path, ""); // call readPubkeyBlacklist Set<byte[]> arr = bl.pubkeyBlacklist; // convert the results to a hashset of strings @@ -164,7 +164,7 @@ public class CertBlacklistTest extends TestCase { private Set<String> getSerialBlacklist(String path) throws IOException { // set our blacklist path - CertBlacklist bl = new CertBlacklist(CertBlacklist.DEFAULT_PUBKEY_BLACKLIST_PATH, path); + CertBlacklist bl = new CertBlacklist("", path); // call readPubkeyBlacklist Set<BigInteger> arr = bl.serialBlacklist; // convert the results to a hashset of strings @@ -249,8 +249,7 @@ public class CertBlacklistTest extends TestCase { // write that to the test blacklist writeBlacklist(new HashSet<String>()); // set our blacklist path - CertBlacklist bl = new CertBlacklist(tmpFile.getCanonicalPath(), - CertBlacklist.DEFAULT_SERIAL_BLACKLIST_PATH); + CertBlacklist bl = new CertBlacklist(tmpFile.getCanonicalPath(), ""); // check to make sure it isn't blacklisted assertEquals(bl.isPublicKeyBlackListed(pk), false); } @@ -265,8 +264,7 @@ public class CertBlacklistTest extends TestCase { testBlackList.add(hash); writeBlacklist(testBlackList); // set our blacklist path - CertBlacklist bl = new CertBlacklist(tmpFile.getCanonicalPath(), - CertBlacklist.DEFAULT_SERIAL_BLACKLIST_PATH); + CertBlacklist bl = new CertBlacklist(tmpFile.getCanonicalPath(), ""); // check to make sure it isn't blacklited assertTrue(bl.isPublicKeyBlackListed(pk)); } diff --git a/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java b/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java index bac8138..1c1296b 100644 --- a/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java +++ b/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java @@ -408,4 +408,16 @@ public class DateIntervalFormatTest extends junit.framework.TestCase { assertEquals("یکشنبه د ۱۹۸۰ د فبروري ۱۰", formatDateRange(new Locale("ps"), utc, thisYear, thisYear, flags)); assertEquals("วันอาทิตย์ 10 กุมภาพันธ์ 1980", formatDateRange(new Locale("th"), utc, thisYear, thisYear, flags)); } + + // http://b/13234532 + public void test13234532() throws Exception { + Locale l = Locale.US; + TimeZone utc = TimeZone.getTimeZone("UTC"); + + int flags = FORMAT_SHOW_TIME | FORMAT_ABBREV_ALL | FORMAT_12HOUR; + + assertEquals("10 – 11 AM", formatDateRange(l, utc, 10*HOUR, 11*HOUR, flags)); + assertEquals("11 AM – 1 PM", formatDateRange(l, utc, 11*HOUR, 13*HOUR, flags)); + assertEquals("2 – 3 PM", formatDateRange(l, utc, 14*HOUR, 15*HOUR, flags)); + } } diff --git a/luni/src/test/java/libcore/icu/NativePluralRulesTest.java b/luni/src/test/java/libcore/icu/NativePluralRulesTest.java index 703a94a..76179b4 100644 --- a/luni/src/test/java/libcore/icu/NativePluralRulesTest.java +++ b/luni/src/test/java/libcore/icu/NativePluralRulesTest.java @@ -19,6 +19,24 @@ package libcore.icu; import java.util.Locale; public class NativePluralRulesTest extends junit.framework.TestCase { + public void testNegatives() throws Exception { + // icu4c's behavior changed, but we prefer to preserve compatibility. + NativePluralRules en_US = NativePluralRules.forLocale(new Locale("en", "US")); + assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(2)); + assertEquals(NativePluralRules.ONE, en_US.quantityForInt(1)); + assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(0)); + assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(-1)); + assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(-2)); + + NativePluralRules ar = NativePluralRules.forLocale(new Locale("ar")); + assertEquals(NativePluralRules.ZERO, ar.quantityForInt(0)); + assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-1)); // Not ONE. + assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-2)); // Not TWO. + assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-3)); // Not FEW. + assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-11)); // Not MANY. + assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-100)); + } + public void testEnglish() throws Exception { NativePluralRules npr = NativePluralRules.forLocale(new Locale("en", "US")); assertEquals(NativePluralRules.OTHER, npr.quantityForInt(0)); diff --git a/luni/src/test/java/libcore/io/OsTest.java b/luni/src/test/java/libcore/io/OsTest.java index cf28122..a0d1e5a 100644 --- a/luni/src/test/java/libcore/io/OsTest.java +++ b/luni/src/test/java/libcore/io/OsTest.java @@ -20,11 +20,14 @@ import android.system.StructUcred; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.InetUnixAddress; import java.net.ServerSocket; import java.net.SocketAddress; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.util.Locale; import junit.framework.TestCase; import static android.system.OsConstants.*; @@ -77,7 +80,7 @@ public class OsTest extends TestCase { assertEquals(Libcore.os.getgid(), credentials.gid); byte[] request = new byte[256]; - int requestLength = Libcore.os.read(clientFd, request, 0, request.length); + Libcore.os.read(clientFd, request, 0, request.length); String s = new String(request, "UTF-8"); byte[] response = s.toUpperCase(Locale.ROOT).getBytes("UTF-8"); @@ -135,4 +138,120 @@ public class OsTest extends TestCase { assertEquals("Killed", Libcore.os.strsignal(9)); assertEquals("Unknown signal -1", Libcore.os.strsignal(-1)); } + + public void test_byteBufferPositions_write_pwrite() throws Exception { + FileOutputStream fos = new FileOutputStream(new File("/dev/null")); + FileDescriptor fd = fos.getFD(); + final byte[] contents = new String("goodbye, cruel world").getBytes(StandardCharsets.US_ASCII); + ByteBuffer byteBuffer = ByteBuffer.wrap(contents); + + byteBuffer.position(0); + int written = Libcore.os.write(fd, byteBuffer); + assertTrue(written > 0); + assertEquals(written, byteBuffer.position()); + + byteBuffer.position(4); + written = Libcore.os.write(fd, byteBuffer); + assertTrue(written > 0); + assertEquals(written + 4, byteBuffer.position()); + + byteBuffer.position(0); + written = Libcore.os.pwrite(fd, byteBuffer, 64 /* offset */); + assertTrue(written > 0); + assertEquals(written, byteBuffer.position()); + + byteBuffer.position(4); + written = Libcore.os.pwrite(fd, byteBuffer, 64 /* offset */); + assertTrue(written > 0); + assertEquals(written + 4, byteBuffer.position()); + + fos.close(); + } + + public void test_byteBufferPositions_read_pread() throws Exception { + FileInputStream fis = new FileInputStream(new File("/dev/zero")); + FileDescriptor fd = fis.getFD(); + ByteBuffer byteBuffer = ByteBuffer.allocate(64); + + byteBuffer.position(0); + int read = Libcore.os.read(fd, byteBuffer); + assertTrue(read > 0); + assertEquals(read, byteBuffer.position()); + + byteBuffer.position(4); + read = Libcore.os.read(fd, byteBuffer); + assertTrue(read > 0); + assertEquals(read + 4, byteBuffer.position()); + + byteBuffer.position(0); + read = Libcore.os.pread(fd, byteBuffer, 64 /* offset */); + assertTrue(read > 0); + assertEquals(read, byteBuffer.position()); + + byteBuffer.position(4); + read = Libcore.os.pread(fd, byteBuffer, 64 /* offset */); + assertTrue(read > 0); + assertEquals(read + 4, byteBuffer.position()); + + fis.close(); + } + + public void test_byteBufferPositions_sendto_recvfrom() throws Exception { + final FileDescriptor serverFd = Libcore.os.socket(AF_INET6, SOCK_STREAM, 0); + Libcore.os.bind(serverFd, InetAddress.getLoopbackAddress(), 0); + Libcore.os.listen(serverFd, 5); + + InetSocketAddress address = (InetSocketAddress) Libcore.os.getsockname(serverFd); + + final Thread server = new Thread(new Runnable() { + public void run() { + try { + InetSocketAddress peerAddress = new InetSocketAddress(); + FileDescriptor clientFd = Libcore.os.accept(serverFd, peerAddress); + + // Attempt to receive a maximum of 24 bytes from the client, and then + // close the connection. + ByteBuffer buffer = ByteBuffer.allocate(16); + int received = Libcore.os.recvfrom(clientFd, buffer, 0, null); + assertTrue(received > 0); + assertEquals(received, buffer.position()); + + ByteBuffer buffer2 = ByteBuffer.allocate(16); + buffer2.position(8); + received = Libcore.os.recvfrom(clientFd, buffer2, 0, null); + assertTrue(received > 0); + assertEquals(received + 8, buffer.position()); + + Libcore.os.close(clientFd); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + }); + + + server.start(); + + FileDescriptor clientFd = Libcore.os.socket(AF_INET6, SOCK_STREAM, 0); + Libcore.os.connect(clientFd, address.getAddress(), address.getPort()); + + final byte[] bytes = "good bye, cruel black hole with fancy distortion".getBytes(StandardCharsets.US_ASCII); + assertTrue(bytes.length > 24); + + ByteBuffer input = ByteBuffer.wrap(bytes); + input.position(0); + input.limit(16); + + int sent = Libcore.os.sendto(clientFd, input, 0, address.getAddress(), address.getPort()); + assertTrue(sent > 0); + assertEquals(sent, input.position()); + + input.position(16); + input.limit(24); + sent = Libcore.os.sendto(clientFd, input, 0, address.getAddress(), address.getPort()); + assertTrue(sent > 0); + assertEquals(sent + 16, input.position()); + + Libcore.os.close(clientFd); + } } diff --git a/luni/src/test/java/libcore/java/io/FileDescriptorTest.java b/luni/src/test/java/libcore/java/io/FileDescriptorTest.java index 4315b81..39472df 100644 --- a/luni/src/test/java/libcore/java/io/FileDescriptorTest.java +++ b/luni/src/test/java/libcore/java/io/FileDescriptorTest.java @@ -17,14 +17,27 @@ package libcore.java.io; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; +import java.net.ServerSocket; import junit.framework.TestCase; public class FileDescriptorTest extends TestCase { - public void testReadOnlyFileDescriptorSync() throws Exception { - File f= File.createTempFile("FileDescriptorTest", "tmp"); - new RandomAccessFile(f, "r").getFD().sync(); - } + public void testReadOnlyFileDescriptorSync() throws Exception { + File f= File.createTempFile("FileDescriptorTest", "tmp"); + new RandomAccessFile(f, "r").getFD().sync(); + } + + public void test_isSocket() throws Exception { + File f = new File("/dev/null"); + FileInputStream fis = new FileInputStream(f); + assertFalse(fis.getFD().isSocket()); + fis.close(); + + ServerSocket s = new ServerSocket(); + assertTrue(s.getImpl$().getFD$().isSocket()); + s.close(); + } } diff --git a/luni/src/test/java/libcore/java/net/URITest.java b/luni/src/test/java/libcore/java/net/URITest.java index 7f4c086..c87433a 100644 --- a/luni/src/test/java/libcore/java/net/URITest.java +++ b/luni/src/test/java/libcore/java/net/URITest.java @@ -702,11 +702,15 @@ public final class URITest extends TestCase { } // http://code.google.com/p/android/issues/detail?id=37577 + // http://b/18023709 + // http://b/17579865 + // http://b/18016625 public void testUnderscore() throws Exception { URI uri = new URI("http://a_b.c.d.net/"); assertEquals("a_b.c.d.net", uri.getAuthority()); - // The RFC's don't permit underscores in hostnames, and neither does URI (unlike URL). - assertNull(uri.getHost()); + // The RFC's don't permit underscores in hostnames, but URI has to because + // a certain large website doesn't seem to care about standards and specs. + assertEquals("a_b.c.d.net", uri.getHost()); } // Adding a new test? Consider adding an equivalent test to URLTest.java diff --git a/luni/src/test/java/libcore/java/net/URLConnectionTest.java b/luni/src/test/java/libcore/java/net/URLConnectionTest.java index b672b19..c09939f 100644 --- a/luni/src/test/java/libcore/java/net/URLConnectionTest.java +++ b/luni/src/test/java/libcore/java/net/URLConnectionTest.java @@ -53,6 +53,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.zip.GZIPInputStream; @@ -770,7 +771,9 @@ public final class URLConnectionTest extends AbstractResourceLeakageDetectorTest } public void testDisconnectedConnection() throws IOException { - server.enqueue(new MockResponse().setBody("ABCDEFGHIJKLMNOPQR")); + server.enqueue(new MockResponse() + .throttleBody(2, 100, TimeUnit.MILLISECONDS) + .setBody("ABCD")); server.play(); HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection(); @@ -778,6 +781,9 @@ public final class URLConnectionTest extends AbstractResourceLeakageDetectorTest assertEquals('A', (char) in.read()); connection.disconnect(); try { + // Reading 'B' may succeed if it's buffered. + in.read(); + // But 'C' shouldn't be buffered (the response is throttled) and this should fail. in.read(); fail("Expected a connection closed exception"); } catch (IOException expected) { @@ -2202,8 +2208,6 @@ public final class URLConnectionTest extends AbstractResourceLeakageDetectorTest assertEquals("This required a 2nd handshake", readAscii(connection.getInputStream(), Integer.MAX_VALUE)); - RecordedRequest first = server.takeRequest(); - assertEquals(0, first.getSequenceNumber()); RecordedRequest retry = server.takeRequest(); assertEquals(0, retry.getSequenceNumber()); assertEquals("SSLv3", retry.getSslProtocol()); diff --git a/luni/src/test/java/libcore/java/nio/channels/SelectorTest.java b/luni/src/test/java/libcore/java/nio/channels/SelectorTest.java index c5f449e..9789197 100644 --- a/luni/src/test/java/libcore/java/nio/channels/SelectorTest.java +++ b/luni/src/test/java/libcore/java/nio/channels/SelectorTest.java @@ -146,32 +146,43 @@ public class SelectorTest extends TestCase { } public void test_57456() throws Exception { - Selector selector = Selector.open(); - ServerSocketChannel ssc = ServerSocketChannel.open(); - - try { - // Connect. - ssc.configureBlocking(false); - ssc.socket().bind(null); - SocketChannel sc = SocketChannel.open(); - sc.connect(ssc.socket().getLocalSocketAddress()); - sc.finishConnect(); - - // Switch to non-blocking so we can use a Selector. - sc.configureBlocking(false); - - // Have the 'server' write something. - ssc.accept().write(ByteBuffer.allocate(128)); - - // At this point, the client should be able to read or write immediately. - // (It shouldn't be able to connect because it's already connected.) - SelectionKey key = sc.register(selector, SelectionKey.OP_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE); - assertEquals(1, selector.select()); - assertEquals(SelectionKey.OP_READ | SelectionKey.OP_WRITE, key.readyOps()); - assertEquals(0, selector.select()); - } finally { + Selector selector = Selector.open(); + ServerSocketChannel ssc = ServerSocketChannel.open(); + + try { + // Connect. + ssc.configureBlocking(false); + ssc.socket().bind(null); + SocketChannel sc = SocketChannel.open(); + sc.connect(ssc.socket().getLocalSocketAddress()); + sc.finishConnect(); + + // Switch to non-blocking so we can use a Selector. + sc.configureBlocking(false); + + // Have the 'server' write something. + ssc.accept().write(ByteBuffer.allocate(128)); + + // At this point, the client should be able to read or write immediately. + // (It shouldn't be able to connect because it's already connected.) + SelectionKey key = sc.register(selector, + SelectionKey.OP_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE); + assertEquals(1, selector.select()); + assertEquals(SelectionKey.OP_READ | SelectionKey.OP_WRITE, key.readyOps()); + assertEquals(0, selector.select()); + } finally { + selector.close(); + ssc.close(); + } + } + + // http://code.google.com/p/android/issues/detail?id=80785 + public void test_80785() throws Exception { + Selector selector = Selector.open(); selector.close(); - ssc.close(); - } + + // Historically on android this did not throw an exception. Due to the bug it would throw + // an (undeclared) IOException. + selector.wakeup(); } } diff --git a/luni/src/test/java/libcore/java/text/DateFormatSymbolsTest.java b/luni/src/test/java/libcore/java/text/DateFormatSymbolsTest.java index 057cd17..e6933e6 100644 --- a/luni/src/test/java/libcore/java/text/DateFormatSymbolsTest.java +++ b/luni/src/test/java/libcore/java/text/DateFormatSymbolsTest.java @@ -147,17 +147,17 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase { } // http://b/7955614 - public void test_getZoneStrings_Apia() throws Exception { + public void test_getZoneStrings_GMT_short_names() throws Exception { String[][] array = DateFormatSymbols.getInstance(Locale.US).getZoneStrings(); for (int i = 0; i < array.length; ++i) { String[] row = array[i]; - // Pacific/Apia is somewhat arbitrary; we just want a zone we have to generate + // America/Santiago is somewhat arbitrary; we just want a zone we have to generate // "GMT" strings for the short names. - if (row[0].equals("Pacific/Apia")) { - assertEquals("Samoa Standard Time", row[1]); - assertEquals("GMT+13:00", row[2]); - assertEquals("Samoa Daylight Time", row[3]); - assertEquals("GMT+14:00", row[4]); + if (row[0].equals("America/Santiago")) { + assertEquals("Chile Standard Time", row[1]); + assertEquals("GMT-03:00", row[2]); + assertEquals("Chile Summer Time", row[3]); + assertEquals("GMT-03:00", row[4]); } } } diff --git a/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java b/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java index 619c38e..3e0aeba 100644 --- a/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java +++ b/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java @@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.text.DecimalFormatSymbols; +import java.util.Currency; import java.util.Locale; public class DecimalFormatSymbolsTest extends junit.framework.TestCase { @@ -57,4 +58,32 @@ public class DecimalFormatSymbolsTest extends junit.framework.TestCase { // The two objects should claim to be equal. assertEquals(originalDfs, deserializedDfs); } + + // https://code.google.com/p/android/issues/detail?id=79925 + public void testSetSameCurrency() throws Exception { + DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US); + dfs.setCurrency(Currency.getInstance("USD")); + assertEquals("$", dfs.getCurrencySymbol()); + dfs.setCurrencySymbol("poop"); + assertEquals("poop", dfs.getCurrencySymbol()); + dfs.setCurrency(Currency.getInstance("USD")); + assertEquals("$", dfs.getCurrencySymbol()); + } + + public void testSetNulInternationalCurrencySymbol() throws Exception { + Currency usd = Currency.getInstance("USD"); + + DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US); + dfs.setCurrency(usd); + assertEquals(usd, dfs.getCurrency()); + assertEquals("$", dfs.getCurrencySymbol()); + assertEquals("USD", dfs.getInternationalCurrencySymbol()); + + // Setting the international currency symbol to null sets the currency to null too, + // but not the currency symbol. + dfs.setInternationalCurrencySymbol(null); + assertEquals(null, dfs.getCurrency()); + assertEquals("$", dfs.getCurrencySymbol()); + assertEquals(null, dfs.getInternationalCurrencySymbol()); + } } diff --git a/luni/src/test/java/libcore/java/text/NumberFormatTest.java b/luni/src/test/java/libcore/java/text/NumberFormatTest.java index 4ff063b..0678e96 100644 --- a/luni/src/test/java/libcore/java/text/NumberFormatTest.java +++ b/luni/src/test/java/libcore/java/text/NumberFormatTest.java @@ -22,6 +22,7 @@ import java.text.DecimalFormatSymbols; import java.text.FieldPosition; import java.text.NumberFormat; import java.text.ParsePosition; +import java.util.Currency; import java.util.Locale; public class NumberFormatTest extends junit.framework.TestCase { @@ -80,6 +81,7 @@ public class NumberFormatTest extends junit.framework.TestCase { // Formatting percentages is confusing but deliberate. // Ensure we don't accidentally "fix" this. + // https://code.google.com/p/android/issues/detail?id=10333 public void test_10333() throws Exception { NumberFormat nf = NumberFormat.getPercentInstance(Locale.US); assertEquals("15%", nf.format(0.15)); @@ -91,6 +93,7 @@ public class NumberFormatTest extends junit.framework.TestCase { } } + // https://code.google.com/p/android/issues/detail?id=62269 public void test_62269() throws Exception { NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); try { @@ -126,4 +129,28 @@ public class NumberFormatTest extends junit.framework.TestCase { fail(); } catch (NullPointerException expected) {} } + + // https://code.google.com/p/android/issues/detail?id=79925 + public void test_setCurrency() throws Exception { + NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); + nf.setCurrency(Currency.getInstance("AMD")); + assertEquals("AMD50.00", nf.format(50.0)); + + DecimalFormatSymbols decimalFormatSymbols = ((DecimalFormat) nf).getDecimalFormatSymbols(); + decimalFormatSymbols.setCurrencySymbol(""); + ((DecimalFormat) nf).setDecimalFormatSymbols(decimalFormatSymbols); + assertEquals("50.00", nf.format(50.0)); + + nf.setCurrency(Currency.getInstance("AMD")); + assertEquals("AMD50.00", nf.format(50.0)); + + nf.setCurrency(Currency.getInstance("AMD")); + assertEquals("AMD50.00", nf.format(50.0)); + + nf.setCurrency(Currency.getInstance("USD")); + assertEquals("$50.00", nf.format(50.0)); + + nf.setCurrency(Currency.getInstance("AMD")); + assertEquals("AMD50.00", nf.format(50.0)); + } } diff --git a/luni/src/test/java/libcore/java/text/OldDateFormatTest.java b/luni/src/test/java/libcore/java/text/OldDateFormatTest.java index df388d3..1bd1d0c 100644 --- a/luni/src/test/java/libcore/java/text/OldDateFormatTest.java +++ b/luni/src/test/java/libcore/java/text/OldDateFormatTest.java @@ -86,6 +86,8 @@ public class OldDateFormatTest extends junit.framework.TestCase { */ public void test_formatLjava_util_Date() { try { + // This test assumes a default DateFormat.is24Hour setting. + DateFormat.is24Hour = null; DateFormat format = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT, Locale.US); Date current = new Date(); @@ -104,6 +106,8 @@ public class OldDateFormatTest extends junit.framework.TestCase { */ public void test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition() { try { + // This test assumes a default DateFormat.is24Hour setting. + DateFormat.is24Hour = null; DateFormat format = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT, Locale.US); Date current = new Date(); @@ -204,6 +208,8 @@ public class OldDateFormatTest extends junit.framework.TestCase { * java.text.DateFormat#parse(String) */ public void test_parseLString() throws Exception { + // This test assumes a default DateFormat.is24Hour setting. + DateFormat.is24Hour = null; DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.US); try { diff --git a/luni/src/test/java/libcore/java/text/SimpleDateFormatTest.java b/luni/src/test/java/libcore/java/text/SimpleDateFormatTest.java index e73104d..d228dc8 100644 --- a/luni/src/test/java/libcore/java/text/SimpleDateFormatTest.java +++ b/luni/src/test/java/libcore/java/text/SimpleDateFormatTest.java @@ -378,4 +378,11 @@ public class SimpleDateFormatTest extends junit.framework.TestCase { fail(); } catch (NullPointerException expected) {} } + + // http://b/17431155 + public void test_sl_dates() throws Exception { + DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, new Locale("sl")); + df.setTimeZone(TimeZone.getTimeZone("UTC")); + assertEquals("1. 1. 70", df.format(0L)); + } } diff --git a/luni/src/test/java/libcore/java/util/TimeZoneTest.java b/luni/src/test/java/libcore/java/util/TimeZoneTest.java index 86a8b7f..1ca950c 100644 --- a/luni/src/test/java/libcore/java/util/TimeZoneTest.java +++ b/luni/src/test/java/libcore/java/util/TimeZoneTest.java @@ -74,52 +74,31 @@ public class TimeZoneTest extends TestCase { } public void testPreHistoricOffsets() throws Exception { - // The "Asia/Saigon" time zone has just a few transitions, and hasn't changed in a - // long time, which is convenient for testing: - // - // libcore.util.ZoneInfo[Asia/Saigon,mRawOffset=25200000,mUseDst=false] - // 0 : time=-2005974400 Fri Jun 08 16:53:20 1906 GMT+00:00 = Fri Jun 08 23:59:40 1906 ICT isDst=0 offset= 380 gmtOffset=25580 - // 1 : time=-1855983920 Fri Mar 10 16:54:40 1911 GMT+00:00 = Fri Mar 10 23:54:40 1911 ICT isDst=0 offset= 0 gmtOffset=25200 - // 2 : time=-1819954800 Tue Apr 30 17:00:00 1912 GMT+00:00 = Wed May 01 01:00:00 1912 ICT isDst=0 offset= 3600 gmtOffset=28800 - // 3 : time=-1220428800 Thu Apr 30 16:00:00 1931 GMT+00:00 = Thu Apr 30 23:00:00 1931 ICT isDst=0 offset= 0 gmtOffset=25200 - TimeZone tz = TimeZone.getTimeZone("Asia/Saigon"); + // "Africa/Bissau" has just a few transitions and hasn't changed in a long time. + // 1912-01-01 00:02:19-0100 ... 1912-01-01 00:02:20-0100 + // 1974-12-31 23:59:59-0100 ... 1975-01-01 01:00:00+0000 + TimeZone tz = TimeZone.getTimeZone("Africa/Bissau"); // Times before our first transition should assume we're still following that transition. - // Note: the RI reports 25600 here because it has more transitions than we do. - assertNonDaylightOffset(25580, -2005975000L, tz); + assertNonDaylightOffset(-3600, parseIsoTime("1911-01-01T00:00:00.0+0000"), tz); - assertNonDaylightOffset(25580, -2005974400L, tz); // 0 - assertNonDaylightOffset(25580, -2005974000L, tz); + assertNonDaylightOffset(-3600, parseIsoTime("1912-01-01T12:00:00.0-0100"), tz); - assertNonDaylightOffset(25200, -1855983920L, tz); // 1 - assertNonDaylightOffset(25200, -1855983900L, tz); - - assertNonDaylightOffset(28800, -1819954800L, tz); // 2 - assertNonDaylightOffset(28800, -1819954000L, tz); - - assertNonDaylightOffset(25200, -1220428800L, tz); // 3 - - // Times after out last transition should assume we're still following that transition. - assertNonDaylightOffset(25200, -1220428000L, tz); - - // There are plenty more examples. "Africa/Bissau" is one: - // - // libcore.util.ZoneInfo[Africa/Bissau,mRawOffset=0,mUseDst=false] - // 0 : time=-1849388260 Fri May 26 01:02:20 1911 GMT+00:00 = Fri May 26 00:02:20 1911 GMT isDst=0 offset=-3600 gmtOffset=-3600 - // 1 : time= 157770000 Wed Jan 01 01:00:00 1975 GMT+00:00 = Wed Jan 01 01:00:00 1975 GMT isDst=0 offset= 0 gmtOffset=0 - tz = TimeZone.getTimeZone("Africa/Bissau"); - assertNonDaylightOffset(-3600, -1849388300L, tz); - assertNonDaylightOffset(-3600, -1849388260L, tz); // 0 - assertNonDaylightOffset(-3600, -1849388200L, tz); - assertNonDaylightOffset(0, 157770000L, tz); // 1 - assertNonDaylightOffset(0, 157780000L, tz); + // Times after our last transition should assume we're still following that transition. + assertNonDaylightOffset(0, parseIsoTime("1980-01-01T00:00:00.0+0000"), tz); } private static void assertNonDaylightOffset(int expectedOffsetSeconds, long epochSeconds, TimeZone tz) { - assertEquals(expectedOffsetSeconds * 1000, tz.getOffset(epochSeconds * 1000)); + assertEquals(expectedOffsetSeconds, tz.getOffset(epochSeconds * 1000) / 1000); assertFalse(tz.inDaylightTime(new Date(epochSeconds * 1000))); } + private static long parseIsoTime(String isoTime) throws Exception { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + Date date = sdf.parse(isoTime); + return date.getTime() / 1000; + } + public void testZeroTransitionZones() throws Exception { // Zones with no transitions historical or future seem ideal for testing. String[] ids = new String[] { "Africa/Bujumbura", "Indian/Cocos", "Pacific/Wake", "UTC" }; @@ -276,21 +255,13 @@ public class TimeZoneTest extends TestCase { assertEquals("", failures.toString()); } - public void testSantiago() throws Exception { + // http://b/7955614 + public void test_getDisplayName_GMT_short_names() throws Exception { TimeZone tz = TimeZone.getTimeZone("America/Santiago"); assertEquals("Chile Summer Time", tz.getDisplayName(true, TimeZone.LONG, Locale.US)); assertEquals("Chile Standard Time", tz.getDisplayName(false, TimeZone.LONG, Locale.US)); assertEquals("GMT-03:00", tz.getDisplayName(true, TimeZone.SHORT, Locale.US)); - assertEquals("GMT-04:00", tz.getDisplayName(false, TimeZone.SHORT, Locale.US)); - } - - // http://b/7955614 - public void testApia() throws Exception { - TimeZone tz = TimeZone.getTimeZone("Pacific/Apia"); - assertEquals("Samoa Daylight Time", tz.getDisplayName(true, TimeZone.LONG, Locale.US)); - assertEquals("Samoa Standard Time", tz.getDisplayName(false, TimeZone.LONG, Locale.US)); - assertEquals("GMT+14:00", tz.getDisplayName(true, TimeZone.SHORT, Locale.US)); - assertEquals("GMT+13:00", tz.getDisplayName(false, TimeZone.SHORT, Locale.US)); + assertEquals("GMT-03:00", tz.getDisplayName(false, TimeZone.SHORT, Locale.US)); } private static boolean isGmtString(String s) { diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java index fb7e0c9..df4585f 100644 --- a/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java +++ b/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java @@ -86,6 +86,32 @@ public class SSLEngineTest extends TestCase { test_SSLEngine_getSupportedCipherSuites_connect(testKeyStore, false); test_SSLEngine_getSupportedCipherSuites_connect(testKeyStore, true); } + + // http://b/18554122 + public void test_SSLEngine_underflowsOnEmptyBuffersDuringHandshake() throws Exception { + final SSLEngine sslEngine = SSLContext.getDefault().createSSLEngine(); + sslEngine.setUseClientMode(false); + ByteBuffer input = ByteBuffer.allocate(1024); + input.flip(); + ByteBuffer output = ByteBuffer.allocate(1024); + sslEngine.beginHandshake(); + assertEquals(SSLEngineResult.HandshakeStatus.NEED_UNWRAP, sslEngine.getHandshakeStatus()); + SSLEngineResult result = sslEngine.unwrap(input, output); + assertEquals(SSLEngineResult.Status.BUFFER_UNDERFLOW, result.getStatus()); + assertEquals(SSLEngineResult.HandshakeStatus.NEED_UNWRAP, result.getHandshakeStatus()); + } + + // http://b/18554122 + public void test_SSLEngine_underflowsOnEmptyBuffersAfterHandshake() throws Exception { + // Note that create performs the handshake. + final TestSSLEnginePair engines = TestSSLEnginePair.create(null /* hooks */); + ByteBuffer input = ByteBuffer.allocate(1024); + input.flip(); + ByteBuffer output = ByteBuffer.allocate(1024); + assertEquals(SSLEngineResult.Status.BUFFER_UNDERFLOW, + engines.client.unwrap(input, output).getStatus()); + } + private void test_SSLEngine_getSupportedCipherSuites_connect(TestKeyStore testKeyStore, boolean secureRenegotiation) throws Exception { diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java index 4681877..4af7f5a 100644 --- a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java +++ b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java @@ -26,6 +26,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; +import java.net.SocketAddress; import java.net.SocketException; import java.net.SocketTimeoutException; import java.security.Principal; @@ -43,6 +44,7 @@ import java.util.concurrent.TimeUnit; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import javax.net.ServerSocketFactory; +import javax.net.SocketFactory; import javax.net.ssl.HandshakeCompletedEvent; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.KeyManager; @@ -1570,6 +1572,28 @@ public class SSLSocketTest extends TestCase { } } + // http://b/18428603 + public void test_SSLSocket_getPortWithSNI() throws Exception { + TestSSLContext context = TestSSLContext.create(); + + SSLSocket client = null; + try { + client = (SSLSocket) context.clientContext.getSocketFactory().createSocket(); + client.connect(new InetSocketAddress(context.host, context.port)); + try { + // This is crucial to reproducing issue 18428603. + Method setHostname = client.getClass().getMethod("setHostname", String.class); + setHostname.invoke(client, "sslsockettest.androidcts.google.com"); + } catch (NoSuchMethodException ignored) { + } + + assertTrue(client.getPort() > 0); + } finally { + client.close(); + context.close(); + } + } + public void test_SSLSocket_sendsTlsFallbackScsv_Fallback_Success() throws Exception { TestSSLContext context = TestSSLContext.create(); @@ -1667,6 +1691,10 @@ public class SSLSocketTest extends TestCase { server.startHandshake(); fail("Should result in inappropriate fallback"); } catch (SSLHandshakeException expected) { + Throwable cause = expected.getCause(); + assertEquals(SSLProtocolException.class, cause.getClass()); + assertTrue(cause.getMessage(), + cause.getMessage().contains("inappropriate fallback")); } return null; } @@ -1679,6 +1707,10 @@ public class SSLSocketTest extends TestCase { client.startHandshake(); fail("Should receive TLS alert inappropriate fallback"); } catch (SSLHandshakeException expected) { + Throwable cause = expected.getCause(); + assertEquals(SSLProtocolException.class, cause.getClass()); + assertTrue(cause.getMessage(), + cause.getMessage().contains("inappropriate fallback")); } return null; } @@ -1692,6 +1724,153 @@ public class SSLSocketTest extends TestCase { context.close(); } + public void test_SSLSocket_ClientGetsAlertDuringHandshake_HasGoodExceptionMessage() + throws Exception { + TestSSLContext context = TestSSLContext.create(); + + final ServerSocket listener = ServerSocketFactory.getDefault().createServerSocket(0); + final SSLSocket client = (SSLSocket) context.clientContext.getSocketFactory().createSocket( + context.host, listener.getLocalPort()); + final Socket server = listener.accept(); + + ExecutorService executor = Executors.newFixedThreadPool(2); + Future<Void> c = executor.submit(new Callable<Void>() { + public Void call() throws Exception { + try { + client.startHandshake(); + fail("Should receive handshake exception"); + } catch (SSLHandshakeException expected) { + assertFalse(expected.getMessage().contains("SSL_ERROR_ZERO_RETURN")); + assertFalse(expected.getMessage().contains("You should never see this.")); + } + return null; + } + }); + Future<Void> s = executor.submit(new Callable<Void>() { + public Void call() throws Exception { + // Wait until the client sends something. + byte[] scratch = new byte[8192]; + server.getInputStream().read(scratch); + + // Write a bogus TLS alert: + // TLSv1.2 Record Layer: Alert (Level: Warning, Description: Protocol Version) + server.getOutputStream().write(new byte[] { + 0x15, 0x03, 0x03, 0x00, 0x02, 0x01, 0x46 + }); + + // TLSv1.2 Record Layer: Alert (Level: Warning, Description: Close Notify) + server.getOutputStream().write(new byte[] { + 0x15, 0x03, 0x03, 0x00, 0x02, 0x01, 0x00 + }); + + return null; + } + }); + + + executor.shutdown(); + c.get(5, TimeUnit.SECONDS); + s.get(5, TimeUnit.SECONDS); + client.close(); + server.close(); + listener.close(); + context.close(); + } + + public void test_SSLSocket_ServerGetsAlertDuringHandshake_HasGoodExceptionMessage() + throws Exception { + TestSSLContext context = TestSSLContext.create(); + + final Socket client = SocketFactory.getDefault().createSocket(context.host, context.port); + final SSLSocket server = (SSLSocket) context.serverSocket.accept(); + + ExecutorService executor = Executors.newFixedThreadPool(2); + Future<Void> s = executor.submit(new Callable<Void>() { + public Void call() throws Exception { + try { + server.startHandshake(); + fail("Should receive handshake exception"); + } catch (SSLHandshakeException expected) { + assertFalse(expected.getMessage().contains("SSL_ERROR_ZERO_RETURN")); + assertFalse(expected.getMessage().contains("You should never see this.")); + } + return null; + } + }); + Future<Void> c = executor.submit(new Callable<Void>() { + public Void call() throws Exception { + // Send bogus ClientHello: + // TLSv1.2 Record Layer: Handshake Protocol: Client Hello + client.getOutputStream().write(new byte[] { + (byte) 0x16, (byte) 0x03, (byte) 0x01, (byte) 0x00, (byte) 0xb9, + (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0xb5, (byte) 0x03, + (byte) 0x03, (byte) 0x5a, (byte) 0x31, (byte) 0xba, (byte) 0x44, + (byte) 0x24, (byte) 0xfd, (byte) 0xf0, (byte) 0x56, (byte) 0x46, + (byte) 0xea, (byte) 0xee, (byte) 0x1c, (byte) 0x62, (byte) 0x8f, + (byte) 0x18, (byte) 0x04, (byte) 0xbd, (byte) 0x1c, (byte) 0xbc, + (byte) 0xbf, (byte) 0x6d, (byte) 0x84, (byte) 0x12, (byte) 0xe9, + (byte) 0x94, (byte) 0xf5, (byte) 0x1c, (byte) 0x15, (byte) 0x3e, + (byte) 0x79, (byte) 0x01, (byte) 0xe2, (byte) 0x00, (byte) 0x00, + (byte) 0x28, (byte) 0xc0, (byte) 0x2b, (byte) 0xc0, (byte) 0x2c, + (byte) 0xc0, (byte) 0x2f, (byte) 0xc0, (byte) 0x30, (byte) 0x00, + (byte) 0x9e, (byte) 0x00, (byte) 0x9f, (byte) 0xc0, (byte) 0x09, + (byte) 0xc0, (byte) 0x0a, (byte) 0xc0, (byte) 0x13, (byte) 0xc0, + (byte) 0x14, (byte) 0x00, (byte) 0x33, (byte) 0x00, (byte) 0x39, + (byte) 0xc0, (byte) 0x07, (byte) 0xc0, (byte) 0x11, (byte) 0x00, + (byte) 0x9c, (byte) 0x00, (byte) 0x9d, (byte) 0x00, (byte) 0x2f, + (byte) 0x00, (byte) 0x35, (byte) 0x00, (byte) 0x05, (byte) 0x00, + (byte) 0xff, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x64, + (byte) 0x00, (byte) 0x0b, (byte) 0x00, (byte) 0x04, (byte) 0x03, + (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x0a, + (byte) 0x00, (byte) 0x34, (byte) 0x00, (byte) 0x32, (byte) 0x00, + (byte) 0x0e, (byte) 0x00, (byte) 0x0d, (byte) 0x00, (byte) 0x19, + (byte) 0x00, (byte) 0x0b, (byte) 0x00, (byte) 0x0c, (byte) 0x00, + (byte) 0x18, (byte) 0x00, (byte) 0x09, (byte) 0x00, (byte) 0x0a, + (byte) 0x00, (byte) 0x16, (byte) 0x00, (byte) 0x17, (byte) 0x00, + (byte) 0x08, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x07, + (byte) 0x00, (byte) 0x14, (byte) 0x00, (byte) 0x15, (byte) 0x00, + (byte) 0x04, (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x12, + (byte) 0x00, (byte) 0x13, (byte) 0x00, (byte) 0x01, (byte) 0x00, + (byte) 0x02, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x0f, + (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x11, (byte) 0x00, + (byte) 0x0d, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x1e, + (byte) 0x06, (byte) 0x01, (byte) 0x06, (byte) 0x02, (byte) 0x06, + (byte) 0x03, (byte) 0x05, (byte) 0x01, (byte) 0x05, (byte) 0x02, + (byte) 0x05, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x04, + (byte) 0x02, (byte) 0x04, (byte) 0x03, (byte) 0x03, (byte) 0x01, + (byte) 0x03, (byte) 0x02, (byte) 0x03, (byte) 0x03, (byte) 0x02, + (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x02, (byte) 0x03, + }); + + // Wait until the server sends something. + byte[] scratch = new byte[8192]; + client.getInputStream().read(scratch); + + // Write a bogus TLS alert: + // TLSv1.2 Record Layer: Alert (Level: Warning, Description: + // Protocol Version) + client.getOutputStream().write(new byte[] { + 0x15, 0x03, 0x03, 0x00, 0x02, 0x01, 0x46 + }); + + // TLSv1.2 Record Layer: Alert (Level: Warning, Description: + // Close Notify) + client.getOutputStream().write(new byte[] { + 0x15, 0x03, 0x03, 0x00, 0x02, 0x01, 0x00 + }); + + return null; + } + }); + + executor.shutdown(); + c.get(5, TimeUnit.SECONDS); + s.get(5, TimeUnit.SECONDS); + client.close(); + server.close(); + context.close(); + } + /** * Not run by default by JUnit, but can be run by Vogar by * specifying it explicitly (or with main method below) diff --git a/luni/src/test/java/libcore/net/MimeUtilsTest.java b/luni/src/test/java/libcore/net/MimeUtilsTest.java index 36476e9..9bfb375 100644 --- a/luni/src/test/java/libcore/net/MimeUtilsTest.java +++ b/luni/src/test/java/libcore/net/MimeUtilsTest.java @@ -42,4 +42,8 @@ public class MimeUtilsTest extends TestCase { assertEquals("png", MimeUtils.guessExtensionFromMimeType("image/png")); assertEquals("zip", MimeUtils.guessExtensionFromMimeType("application/zip")); } + + public void test_18390752() { + assertEquals("jpg", MimeUtils.guessExtensionFromMimeType("image/jpeg")); + } } diff --git a/luni/src/test/java/libcore/xml/KxmlSerializerTest.java b/luni/src/test/java/libcore/xml/KxmlSerializerTest.java index 6a75a9b..5f68a99 100644 --- a/luni/src/test/java/libcore/xml/KxmlSerializerTest.java +++ b/luni/src/test/java/libcore/xml/KxmlSerializerTest.java @@ -22,7 +22,9 @@ import java.io.StringWriter; import junit.framework.TestCase; import org.kxml2.io.KXmlSerializer; import org.w3c.dom.Document; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.w3c.dom.Text; import org.xmlpull.v1.XmlSerializer; import static tests.support.Support_Xml.domOf; @@ -87,12 +89,67 @@ public final class KxmlSerializerTest extends TestCase { return serializer; } + public String fromCodePoint(int codePoint) { + if (codePoint > Character.MAX_VALUE) { + return new String(Character.toChars(codePoint)); + } + return Character.toString((char) codePoint); + } + + // http://b/17960630 + public void testSpeakNoEvilMonkeys() throws Exception { + StringWriter stringWriter = new StringWriter(); + XmlSerializer serializer = new KXmlSerializer(); + serializer.setOutput(stringWriter); + serializer.startDocument("UTF-8", null); + serializer.startTag(NAMESPACE, "tag"); + serializer.attribute(NAMESPACE, "attr", "a\ud83d\ude4ab"); + serializer.text("c\ud83d\ude4ad"); + serializer.cdsect("e\ud83d\ude4af"); + serializer.endTag(NAMESPACE, "tag"); + serializer.endDocument(); + assertXmlEquals("<tag attr=\"a🙊b\">" + + "c🙊d" + + "<![CDATA[e]]>🙊<![CDATA[f]]>" + + "</tag>", stringWriter.toString()); + + // Check we can parse what we just output. + Document doc = domOf(stringWriter.toString()); + Node root = doc.getDocumentElement(); + assertEquals("a\ud83d\ude4ab", root.getAttributes().getNamedItem("attr").getNodeValue()); + Text text = (Text) root.getFirstChild(); + assertEquals("c\ud83d\ude4ade\ud83d\ude4af", text.getNodeValue()); + } + + public void testBadSurrogates() throws Exception { + StringWriter stringWriter = new StringWriter(); + XmlSerializer serializer = new KXmlSerializer(); + serializer.setOutput(stringWriter); + serializer.startDocument("UTF-8", null); + serializer.startTag(NAMESPACE, "tag"); + try { + serializer.attribute(NAMESPACE, "attr", "a\ud83d\u0040b"); + } catch (IllegalArgumentException expected) { + } + try { + serializer.text("c\ud83d\u0040d"); + } catch (IllegalArgumentException expected) { + } + try { + serializer.cdsect("e\ud83d\u0040f"); + } catch (IllegalArgumentException expected) { + } + } + + // Cover all the BMP code points plus a few that require us to use surrogates. + private static int MAX_TEST_CODE_POINT = 0x10008; + public void testInvalidCharactersInText() throws IOException { XmlSerializer serializer = newSerializer(); serializer.startTag(NAMESPACE, "root"); - for (int ch = 0; ch <= 0xffff; ++ch) { - final String s = Character.toString((char) ch); - if (isValidXmlCodePoint(ch)) { + for (int c = 0; c <= MAX_TEST_CODE_POINT; ++c) { + final String s = fromCodePoint(c); + if (isValidXmlCodePoint(c)) { serializer.text("a" + s + "b"); } else { try { @@ -108,9 +165,9 @@ public final class KxmlSerializerTest extends TestCase { public void testInvalidCharactersInAttributeValues() throws IOException { XmlSerializer serializer = newSerializer(); serializer.startTag(NAMESPACE, "root"); - for (int ch = 0; ch <= 0xffff; ++ch) { - final String s = Character.toString((char) ch); - if (isValidXmlCodePoint(ch)) { + for (int c = 0; c <= MAX_TEST_CODE_POINT; ++c) { + final String s = fromCodePoint(c); + if (isValidXmlCodePoint(c)) { serializer.attribute(NAMESPACE, "a", "a" + s + "b"); } else { try { @@ -126,9 +183,9 @@ public final class KxmlSerializerTest extends TestCase { public void testInvalidCharactersInCdataSections() throws IOException { XmlSerializer serializer = newSerializer(); serializer.startTag(NAMESPACE, "root"); - for (int ch = 0; ch <= 0xffff; ++ch) { - final String s = Character.toString((char) ch); - if (isValidXmlCodePoint(ch)) { + for (int c = 0; c <= MAX_TEST_CODE_POINT; ++c) { + final String s = fromCodePoint(c); + if (isValidXmlCodePoint(c)) { serializer.cdsect("a" + s + "b"); } else { try { diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java index 5258fd1..abf06e0 100644 --- a/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java +++ b/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java @@ -834,8 +834,8 @@ public class HttpsURLConnectionTest extends TestCase { } @Override - public SocketPolicy peekSocketPolicy() { - return delegates.getFirst().peekSocketPolicy(); + public MockResponse peek() { + return delegates.getFirst().peek(); } } @@ -888,8 +888,8 @@ public class HttpsURLConnectionTest extends TestCase { } @Override - public SocketPolicy peekSocketPolicy() { - return SocketPolicy.UPGRADE_TO_SSL_AT_END; + public MockResponse peek() { + return new MockResponse().setSocketPolicy(SocketPolicy.UPGRADE_TO_SSL_AT_END); } private void log(String msg) { @@ -939,8 +939,8 @@ public class HttpsURLConnectionTest extends TestCase { } @Override - public SocketPolicy peekSocketPolicy() { - return SocketPolicy.DISCONNECT_AT_END; + public MockResponse peek() { + return new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AT_END); } private void log(String msg) { |