*) Bugfix for ArrayIndexOutOfBoundsException during SSL detection

See: http://www.yacy-forum.de/viewtopic.php?p=28247#28247

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3025 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent 5afd2f283c
commit 954db729db

@ -77,9 +77,17 @@ public class serverCoreSocket extends Socket {
private void detectSSL() throws IOException { private void detectSSL() throws IOException {
InputStream in = getInputStream(); InputStream in = getInputStream();
// read the first 6 bytes to determine the protocol type // read the first 5 bytes to determine the protocol type
byte[] preRead = new byte[5]; byte[] preRead = new byte[5];
int read = in.read(preRead); int read, count = 0;
while ((count < preRead.length) && ((read = in.read()) != -1)) {
preRead[count] = (byte) read;
count++;
}
if (count < preRead.length) {
((PushbackInputStream) in).unread(preRead,0,count);
return;
}
int idx = 0; int idx = 0;
if ((preRead[0] & 0xFF) == 22) { if ((preRead[0] & 0xFF) == 22) {
@ -114,7 +122,7 @@ public class serverCoreSocket extends Socket {
} }
// unread pre read bytes // unread pre read bytes
((PushbackInputStream) in).unread(preRead,0,read); ((PushbackInputStream) in).unread(preRead);
} }
public InetAddress getInetAddress() { public InetAddress getInetAddress() {

Loading…
Cancel
Save