Skip to content

Commit dae2539

Browse files
committed
Fix Java::JavaLang::StringIndexOutOfBoundsException on ctx.cipher=[]
1 parent dd260b6 commit dae2539

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/java/org/jruby/ext/openssl/CipherStrings.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,10 @@ static Collection<Def> matchingCiphers(final String cipherString, final String[]
512512
}
513513

514514
int index = 0;
515-
switch ( part.charAt(0) ) {
516-
case '!': case '+': case '-': index++; break;
515+
if (part.length() > 0) {
516+
switch ( part.charAt(0) ) {
517+
case '!': case '+': case '-': index++; break;
518+
}
517519
}
518520

519521
final Collection<Def> matching;

src/test/ruby/ssl/test_context.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,12 @@ def test_context_ciphers
178178
assert_equal [], diff
179179
end unless java7? # would need to filter out stuff such as ECDHE-RSA-AES128-GCM-SHA256
180180

181+
def test_set_ciphers_empty_array
182+
context = OpenSSL::SSL::SSLContext.new
183+
ex = assert_raise(OpenSSL::SSL::SSLError) do
184+
context.ciphers = []
185+
end
186+
assert_equal "no cipher match", ex.message
187+
end
188+
181189
end

0 commit comments

Comments
 (0)