summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2009-11-24 13:31:39 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2009-11-24 13:31:39 -0800
commit137dee17abcf38d04b946ef658258c3ddb6714ef (patch)
tree765dc96e117b996e2942213160db04d43558c3c6
parent1072631d16a5e5ffd97ae346e20dcd112df9dc13 (diff)
parent94aaa41701514731d1e3a9f48e7212cb8e3a16d7 (diff)
downloadlibcore-137dee17abcf38d04b946ef658258c3ddb6714ef.zip
libcore-137dee17abcf38d04b946ef658258c3ddb6714ef.tar.gz
libcore-137dee17abcf38d04b946ef658258c3ddb6714ef.tar.bz2
am e732bb04: am 1c7705b6: Merge change I96996494 into eclair-mr2
Merge commit 'e732bb040be84bd2ac652ca53330b80367a65725' * commit 'e732bb040be84bd2ac652ca53330b80367a65725': Fix browser crashes if server certificates have > 32 subjectAltNames.
-rw-r--r--security/src/main/java/org/bouncycastle/asn1/x509/X509Name.java5
-rw-r--r--security/src/main/java/org/bouncycastle/asn1/x509/X509NameElementList.java45
2 files changed, 15 insertions, 35 deletions
diff --git a/security/src/main/java/org/bouncycastle/asn1/x509/X509Name.java b/security/src/main/java/org/bouncycastle/asn1/x509/X509Name.java
index 0111962..c3e1f46 100644
--- a/security/src/main/java/org/bouncycastle/asn1/x509/X509Name.java
+++ b/security/src/main/java/org/bouncycastle/asn1/x509/X509Name.java
@@ -9,11 +9,6 @@ import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.util.encoders.Hex;
import org.bouncycastle.util.Strings;
-// BEGIN android-note
-// Changes to this class now limit X509Names to 32 components. We have
-// never observed an instance created with more than 10.
-// END android-note
-
/**
* <pre>
* RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
diff --git a/security/src/main/java/org/bouncycastle/asn1/x509/X509NameElementList.java b/security/src/main/java/org/bouncycastle/asn1/x509/X509NameElementList.java
index 752cfeb..377fb8c 100644
--- a/security/src/main/java/org/bouncycastle/asn1/x509/X509NameElementList.java
+++ b/security/src/main/java/org/bouncycastle/asn1/x509/X509NameElementList.java
@@ -1,12 +1,12 @@
package org.bouncycastle.asn1.x509;
+import java.util.ArrayList;
+import java.util.BitSet;
import org.bouncycastle.asn1.DERObjectIdentifier;
// BEGIN android-note
// This class was extracted from X509Name as a way to keep the element
-// list in a more controlled fashion. Also, unlike the original code,
-// this class imposes a 32 element limit. We have never observed an
-// instance created with more than 10, so the limit seems reasonable.
+// list in a more controlled fashion.
// END android-note
/**
@@ -42,10 +42,10 @@ public class X509NameElementList {
* null-ok; array of additional keys and values, alternating
* key then value, etc.
*/
- private Object[] rest;
+ private ArrayList<Object> rest;
- /** bit vector (in int form) for all the "added" bits */
- private int added;
+ /** bit vector for all the "added" bits */
+ private BitSet added = new BitSet();
/** &gt;= 0; number of elements in the list */
private int size;
@@ -70,11 +70,6 @@ public class X509NameElementList {
* @param added the added bit
*/
public void add(DERObjectIdentifier key, String value, boolean added) {
- if (size >= 32) {
- throw new UnsupportedOperationException(
- "no more than 32 elements");
- }
-
if (key == null) {
throw new NullPointerException("key == null");
}
@@ -108,28 +103,18 @@ public class X509NameElementList {
}
case 4: {
// Do initial allocation of rest.
- rest = new Object[10];
- rest[0] = key;
- rest[1] = value;
- break;
- }
- case 9: {
- // Grow to accommodate 28 pairs in the array.
- Object[] newRest = new Object[56];
- System.arraycopy(rest, 0, newRest, 0, 10);
- rest = newRest;
- // Fall through.
+ rest = new ArrayList<Object>();
+ // Fall through...
}
default: {
- int index = (sz - 4) * 2;
- rest[index] = key;
- rest[index + 1] = value;
+ rest.add(key);
+ rest.add(value);
break;
}
}
if (added) {
- this.added |= (1 << sz);
+ this.added.set(sz);
}
size = sz + 1;
@@ -139,7 +124,7 @@ public class X509NameElementList {
* Sets the "added" flag on the most recently added element.
*/
public void setLastAddedFlag() {
- added |= 1 << (size - 1);
+ added.set(size - 1);
}
/**
@@ -165,7 +150,7 @@ public class X509NameElementList {
case 1: return key1;
case 2: return key2;
case 3: return key3;
- default: return (DERObjectIdentifier) rest[(n - 4) * 2];
+ default: return (DERObjectIdentifier) rest.get((n - 4) * 2);
}
}
@@ -185,7 +170,7 @@ public class X509NameElementList {
case 1: return value1;
case 2: return value2;
case 3: return value3;
- default: return (String) rest[((n - 4) * 2) + 1];
+ default: return (String) rest.get(((n - 4) * 2) + 1);
}
}
@@ -200,7 +185,7 @@ public class X509NameElementList {
throw new IndexOutOfBoundsException(Integer.toString(n));
}
- return (added & (1 << n)) != 0;
+ return added.get(n);
}
/**