Loading core/java/android/net/SSLCertificateSocketFactory.java +5 −2 Original line number Diff line number Diff line Loading @@ -261,8 +261,8 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { * server then the first protocol in the client's list will be selected. * The order of the client's protocols is otherwise insignificant. * * @param npnProtocols a possibly-empty list of protocol byte arrays. All * arrays must be non-empty and of length less than 256. * @param npnProtocols a non-empty list of protocol byte arrays. All arrays * must be non-empty and of length less than 256. */ public void setNpnProtocols(byte[][] npnProtocols) { this.mNpnProtocols = toNpnProtocolsList(npnProtocols); Loading @@ -273,6 +273,9 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { * strings. */ static byte[] toNpnProtocolsList(byte[]... npnProtocols) { if (npnProtocols.length == 0) { throw new IllegalArgumentException("npnProtocols.length == 0"); } int totalLength = 0; for (byte[] s : npnProtocols) { if (s.length == 0 || s.length > 255) { Loading core/tests/coretests/src/android/net/SSLTest.java +8 −5 Original line number Diff line number Diff line Loading @@ -59,17 +59,20 @@ public class SSLTest extends TestCase { new byte[] { 'h', 't', 't', 'p', '/', '1', '.', '1' }))); } public void testStringsToNpnBytesEmptyByteArray() { public void testStringsToNpnBytesEmptyArray() { try { SSLCertificateSocketFactory.toNpnProtocolsList(new byte[0]); SSLCertificateSocketFactory.toNpnProtocolsList(); fail(); } catch (IllegalArgumentException expected) { } } public void testStringsToNpnBytesEmptyArray() { byte[] expected = {}; assertTrue(Arrays.equals(expected, SSLCertificateSocketFactory.toNpnProtocolsList())); public void testStringsToNpnBytesEmptyByteArray() { try { SSLCertificateSocketFactory.toNpnProtocolsList(new byte[0]); fail(); } catch (IllegalArgumentException expected) { } } public void testStringsToNpnBytesOversizedInput() { Loading Loading
core/java/android/net/SSLCertificateSocketFactory.java +5 −2 Original line number Diff line number Diff line Loading @@ -261,8 +261,8 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { * server then the first protocol in the client's list will be selected. * The order of the client's protocols is otherwise insignificant. * * @param npnProtocols a possibly-empty list of protocol byte arrays. All * arrays must be non-empty and of length less than 256. * @param npnProtocols a non-empty list of protocol byte arrays. All arrays * must be non-empty and of length less than 256. */ public void setNpnProtocols(byte[][] npnProtocols) { this.mNpnProtocols = toNpnProtocolsList(npnProtocols); Loading @@ -273,6 +273,9 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { * strings. */ static byte[] toNpnProtocolsList(byte[]... npnProtocols) { if (npnProtocols.length == 0) { throw new IllegalArgumentException("npnProtocols.length == 0"); } int totalLength = 0; for (byte[] s : npnProtocols) { if (s.length == 0 || s.length > 255) { Loading
core/tests/coretests/src/android/net/SSLTest.java +8 −5 Original line number Diff line number Diff line Loading @@ -59,17 +59,20 @@ public class SSLTest extends TestCase { new byte[] { 'h', 't', 't', 'p', '/', '1', '.', '1' }))); } public void testStringsToNpnBytesEmptyByteArray() { public void testStringsToNpnBytesEmptyArray() { try { SSLCertificateSocketFactory.toNpnProtocolsList(new byte[0]); SSLCertificateSocketFactory.toNpnProtocolsList(); fail(); } catch (IllegalArgumentException expected) { } } public void testStringsToNpnBytesEmptyArray() { byte[] expected = {}; assertTrue(Arrays.equals(expected, SSLCertificateSocketFactory.toNpnProtocolsList())); public void testStringsToNpnBytesEmptyByteArray() { try { SSLCertificateSocketFactory.toNpnProtocolsList(new byte[0]); fail(); } catch (IllegalArgumentException expected) { } } public void testStringsToNpnBytesOversizedInput() { Loading