Program: 143945
Project: 143945
Buggy source:
private byte[] handlePacket(byte packetType,byte[] packetData) throws IOException {
  byte b;
  int boffset=0;
  if (debug > 0)   System.out.println("String_Node_Str");
switch (packetType) {
case SSH_MSG_DISCONNECT:
    String str=SshMisc.getString(boffset,packetData);
  disconnect();
return str.getBytes();
case SSH_SMSG_PUBLIC_KEY:
byte[] anti_spoofing_cookie=new byte[8];
byte[] server_key_bits=new byte[4];
byte[] server_key_public_exponent;
byte[] server_key_public_modulus;
byte[] host_key_bits=new byte[4];
byte[] host_key_public_exponent;
byte[] host_key_public_modulus;
byte[] protocol_flags=new byte[4];
byte[] supported_ciphers_mask=new byte[4];
byte[] supported_authentications_mask=new byte[4];
for (int i=0; i <= 7; i++) anti_spoofing_cookie[i]=packetData[boffset++];
for (int i=0; i <= 3; i++) server_key_bits[i]=packetData[boffset++];
server_key_public_exponent=SshMisc.getMpInt(boffset,packetData);
boffset+=server_key_public_exponent.length + 2;
server_key_public_modulus=SshMisc.getMpInt(boffset,packetData);
boffset+=server_key_public_modulus.length + 2;
for (int i=0; i <= 3; i++) host_key_bits[i]=packetData[boffset++];
host_key_public_exponent=SshMisc.getMpInt(boffset,packetData);
boffset+=host_key_public_exponent.length + 2;
host_key_public_modulus=SshMisc.getMpInt(boffset,packetData);
boffset+=host_key_public_modulus.length + 2;
for (int i=0; i < 4; i++) protocol_flags[i]=packetData[boffset++];
for (int i=0; i < 4; i++) supported_ciphers_mask[i]=packetData[boffset++];
for (int i=0; i < 4; i++) supported_authentications_mask[i]=packetData[boffset++];
Send_SSH_CMSG_SESSION_KEY(anti_spoofing_cookie,server_key_public_modulus,host_key_public_modulus,supported_ciphers_mask,server_key_public_exponent,host_key_public_exponent);
if (hashHostKey != null && hashHostKey.compareTo("String_Node_Str") != 0) {
byte[] Md5_hostKey=MD5.hash(host_key_public_modulus);
String hashHostKeyBis="String_Node_Str";
for (int i=0; i < Md5_hostKey.length; i++) {
String hex="String_Node_Str";
int[] v=new int[2];
v[0]=(Md5_hostKey[i] & 240) >> 4;
v[1]=(Md5_hostKey[i] & 15);
for (int j=0; j < 1; j++) switch (v[j]) {
case 10:
hex+="String_Node_Str";
break;
case 11:
hex+="String_Node_Str";
break;
case 12:
hex+="String_Node_Str";
break;
case 13:
hex+="String_Node_Str";
break;
case 14:
hex+="String_Node_Str";
break;
case 15:
hex+="String_Node_Str";
break;
default :
hex+=String.valueOf(v[j]);
break;
}
hashHostKeyBis=hashHostKeyBis + hex;
}
if (hashHostKeyBis.compareTo(hashHostKey) != 0) {
login=password="String_Node_Str";
return ("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str").getBytes();
}
}
break;
case SSH_SMSG_SUCCESS:
if (lastPacketSentType == SSH_CMSG_SESSION_KEY) {
Send_SSH_CMSG_USER();
break;
}
if (lastPacketSentType == SSH_CMSG_AUTH_PASSWORD) {
System.out.println("String_Node_Str");
Send_SSH_CMSG_REQUEST_PTY();
return "String_Node_Str".getBytes();
}
if (lastPacketSentType == SSH_CMSG_REQUEST_PTY) {
Send_SSH_CMSG_EXEC_SHELL();
break;
}
break;
case SSH_SMSG_FAILURE:
if (lastPacketSentType == SSH_CMSG_AUTH_PASSWORD) {
System.out.println("String_Node_Str");
return "String_Node_Str".getBytes();
}
if (lastPacketSentType == SSH_CMSG_USER) {
Send_SSH_CMSG_AUTH_PASSWORD();
break;
}
if (lastPacketSentType == SSH_CMSG_REQUEST_PTY) {
break;
}
break;
case SSH_SMSG_STDOUT_DATA:
str=SshMisc.getString(0,packetData);
return str.getBytes();
case SSH_SMSG_STDERR_DATA:
str="String_Node_Str" + SshMisc.getString(0,packetData);
System.out.println("String_Node_Str" + "String_Node_Str" + str);
return str.getBytes();
case SSH_SMSG_EXITSTATUS:
int value=(packetData[0] << 24) + (packetData[1] << 16) + (packetData[2] << 8)+ (packetData[3]);
Send_SSH_CMSG_EXIT_CONFIRMATION();
System.out.println("String_Node_Str" + value);
disconnect();
break;
case SSH_MSG_DEBUG:
str=SshMisc.getString(0,packetData);
System.out.println("String_Node_Str" + "String_Node_Str" + str);
if (lastPacketSentType == SSH_CMSG_USER) {
Send_SSH_CMSG_REQUEST_PTY();
break;
}
return str.getBytes();
default :
System.err.print("String_Node_Str" + packetType);
break;
}
return null;
}

Fixed version (ground truth):
private byte[] handlePacket(byte packetType,byte[] packetData) throws IOException {
  byte b;
  int boffset=0;
  if (debug > 0)   System.out.println("String_Node_Str" + packetType);
switch (packetType) {
case SSH_MSG_DISCONNECT:
    String str=SshMisc.getString(boffset,packetData);
  disconnect();
return str.getBytes();
case SSH_SMSG_PUBLIC_KEY:
byte[] anti_spoofing_cookie=new byte[8];
byte[] server_key_bits=new byte[4];
byte[] server_key_public_exponent;
byte[] server_key_public_modulus;
byte[] host_key_bits=new byte[4];
byte[] host_key_public_exponent;
byte[] host_key_public_modulus;
byte[] protocol_flags=new byte[4];
byte[] supported_ciphers_mask=new byte[4];
byte[] supported_authentications_mask=new byte[4];
for (int i=0; i <= 7; i++) anti_spoofing_cookie[i]=packetData[boffset++];
for (int i=0; i <= 3; i++) server_key_bits[i]=packetData[boffset++];
server_key_public_exponent=SshMisc.getMpInt(boffset,packetData);
boffset+=server_key_public_exponent.length + 2;
server_key_public_modulus=SshMisc.getMpInt(boffset,packetData);
boffset+=server_key_public_modulus.length + 2;
for (int i=0; i <= 3; i++) host_key_bits[i]=packetData[boffset++];
host_key_public_exponent=SshMisc.getMpInt(boffset,packetData);
boffset+=host_key_public_exponent.length + 2;
host_key_public_modulus=SshMisc.getMpInt(boffset,packetData);
boffset+=host_key_public_modulus.length + 2;
for (int i=0; i < 4; i++) protocol_flags[i]=packetData[boffset++];
for (int i=0; i < 4; i++) supported_ciphers_mask[i]=packetData[boffset++];
for (int i=0; i < 4; i++) supported_authentications_mask[i]=packetData[boffset++];
Send_SSH_CMSG_SESSION_KEY(anti_spoofing_cookie,server_key_public_modulus,host_key_public_modulus,supported_ciphers_mask,server_key_public_exponent,host_key_public_exponent);
if (hashHostKey != null && hashHostKey.compareTo("String_Node_Str") != 0) {
byte[] Md5_hostKey=MD5.hash(host_key_public_modulus);
String hashHostKeyBis="String_Node_Str";
for (int i=0; i < Md5_hostKey.length; i++) {
String hex="String_Node_Str";
int[] v=new int[2];
v[0]=(Md5_hostKey[i] & 240) >> 4;
v[1]=(Md5_hostKey[i] & 15);
for (int j=0; j < 1; j++) switch (v[j]) {
case 10:
hex+="String_Node_Str";
break;
case 11:
hex+="String_Node_Str";
break;
case 12:
hex+="String_Node_Str";
break;
case 13:
hex+="String_Node_Str";
break;
case 14:
hex+="String_Node_Str";
break;
case 15:
hex+="String_Node_Str";
break;
default :
hex+=String.valueOf(v[j]);
break;
}
hashHostKeyBis=hashHostKeyBis + hex;
}
if (hashHostKeyBis.compareTo(hashHostKey) != 0) {
login=password="String_Node_Str";
return ("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str").getBytes();
}
}
break;
case SSH_SMSG_SUCCESS:
if (lastPacketSentType == SSH_CMSG_SESSION_KEY) {
Send_SSH_CMSG_USER();
break;
}
if (lastPacketSentType == SSH_CMSG_AUTH_PASSWORD) {
System.out.println("String_Node_Str");
Send_SSH_CMSG_REQUEST_PTY();
return "String_Node_Str".getBytes();
}
if (lastPacketSentType == SSH_CMSG_REQUEST_PTY) {
Send_SSH_CMSG_EXEC_SHELL();
break;
}
break;
case SSH_SMSG_FAILURE:
if (lastPacketSentType == SSH_CMSG_AUTH_PASSWORD) {
System.out.println("String_Node_Str");
return "String_Node_Str".getBytes();
}
if (lastPacketSentType == SSH_CMSG_USER) {
Send_SSH_CMSG_AUTH_PASSWORD();
break;
}
if (lastPacketSentType == SSH_CMSG_REQUEST_PTY) {
break;
}
break;
case SSH_SMSG_STDOUT_DATA:
str=SshMisc.getString(0,packetData);
return str.getBytes();
case SSH_SMSG_STDERR_DATA:
str="String_Node_Str" + SshMisc.getString(0,packetData);
System.out.println("String_Node_Str" + "String_Node_Str" + str);
return str.getBytes();
case SSH_SMSG_EXITSTATUS:
int value=(packetData[0] << 24) + (packetData[1] << 16) + (packetData[2] << 8)+ (packetData[3]);
Send_SSH_CMSG_EXIT_CONFIRMATION();
System.out.println("String_Node_Str" + value);
disconnect();
break;
case SSH_MSG_DEBUG:
str=SshMisc.getString(0,packetData);
System.out.println("String_Node_Str" + "String_Node_Str" + str);
if (lastPacketSentType == SSH_CMSG_USER) {
Send_SSH_CMSG_AUTH_PASSWORD();
break;
}
return str.getBytes();
default :
System.err.print("String_Node_Str" + packetType);
break;
}
return null;
}