Program: 1512
Project: 1512
Buggy source:
@Override protected boolean authUser(Session session,byte[] password) throws Exception {
  super.authUser(session,password);
  byte[] passphrase=null;
  final Set<Identity> identities=IdentityManager.getManager().getIdentities();
synchronized (identities) {
    if (identities.isEmpty()) {
      return false;
    }
    identityLoop:     for (    Identity identity : identities) {
      byte[] pubkeyblob=identity.getPublicKeyBlob();
      if (pubkeyblob != null) {
        _packet.reset();
        _buffer.putByte(SSH_MSG_USERAUTH_REQUEST);
        _buffer.putString(session.getUserName());
        _buffer.putString(SSH_CONNECTION);
        _buffer.putString(UserAuth.PUBLICKEY);
        _buffer.putByte((byte)0);
        _buffer.putString(identity.getAlgorithmName());
        _buffer.putString(pubkeyblob);
        session.write(_packet);
        loop1:         while (true) {
switch (session.read(_buffer).getCommand() & 0xff) {
case SSH_MSG_USERAUTH_BANNER:
            userAuthBanner();
          continue loop1;
case SSH_MSG_USERAUTH_PK_OK:
        break loop1;
case SSH_MSG_USERAUTH_FAILURE:
default :
      continue identityLoop;
  }
}
}
int count=5;
while (count-- > 0) {
if (identity.isEncrypted()) {
  if (_userinfo == null) {
    throw new JSchException("String_Node_Str");
  }
 else   if (!_userinfo.promptPassphrase(String.format(MessageConstants.PROMPT_PASSPHRASE,identity.getName()))) {
    throw new AuthCancelException("String_Node_Str");
  }
  if (_userinfo.getPassphrase() != null) {
    passphrase=Util.str2byte(_userinfo.getPassphrase());
  }
}
if ((!identity.isEncrypted() || passphrase != null) && identity.setPassphrase(passphrase)) {
  break;
}
Util.bzero(passphrase);
passphrase=null;
}
Util.bzero(passphrase);
passphrase=null;
if (identity.isEncrypted()) {
continue;
}
if (pubkeyblob == null) {
pubkeyblob=identity.getPublicKeyBlob();
}
if (pubkeyblob == null) {
continue;
}
_packet.reset();
_buffer.setOffSet(0);
_buffer.putByte(SSH_MSG_USERAUTH_REQUEST);
_buffer.putString(session.getUserName());
_buffer.putString(SSH_CONNECTION);
_buffer.putString(UserAuth.PUBLICKEY);
_buffer.putByte((byte)1);
_buffer.putString(identity.getAlgorithmName());
_buffer.putString(pubkeyblob);
byte[] sid=session.getSessionId();
byte[] tmpData=new byte[4 + sid.length + _buffer.getLength() - 5];
Buffer tmp=new Buffer(tmpData);
tmp.putString(sid);
tmp.putBytes(_buffer,5,_buffer.getLength() - 5);
byte[] signature=identity.getSignature(tmpData);
if (signature == null) {
break;
}
_buffer.putString(signature);
session.write(_packet);
loop2: while (true) {
switch (session.read(_buffer).getCommand() & 0xff) {
case SSH_MSG_USERAUTH_SUCCESS:
  return true;
case SSH_MSG_USERAUTH_BANNER:
userAuthBanner();
continue loop2;
case SSH_MSG_USERAUTH_FAILURE:
userAuthFailure();
break loop2;
}
break;
}
}
}
return false;
}

Fixed version (ground truth):
@Override protected boolean authUser(Session session,byte[] password) throws Exception {
  super.authUser(session,password);
  byte[] passphrase=null;
  final Set<Identity> identities=IdentityManager.getManager().getIdentities();
synchronized (identities) {
    if (identities.isEmpty()) {
      return false;
    }
    for (    Identity identity : identities) {
      byte[] pubkeyblob=identity.getPublicKeyBlob();
      if (pubkeyblob != null) {
        _packet.reset();
        _buffer.putByte(SSH_MSG_USERAUTH_REQUEST);
        _buffer.putString(session.getUserName());
        _buffer.putString(SSH_CONNECTION);
        _buffer.putString(UserAuth.PUBLICKEY);
        _buffer.putByte((byte)0);
        _buffer.putString(identity.getAlgorithmName());
        _buffer.putString(pubkeyblob);
        session.write(_packet);
        boolean read_more=true;
        boolean failed=false;
        while (read_more) {
switch (session.read(_buffer).getCommand() & 0xff) {
case SSH_MSG_USERAUTH_BANNER:
            userAuthBanner();
          break;
case SSH_MSG_USERAUTH_PK_OK:
        read_more=false;
      break;
case SSH_MSG_USERAUTH_FAILURE:
default :
    failed=true;
  read_more=false;
}
}
if (failed) continue;
}
int count=5;
while (count-- > 0) {
if (identity.isEncrypted()) {
if (_userinfo == null) {
throw new JSchException("String_Node_Str");
}
 else if (!_userinfo.promptPassphrase(String.format(MessageConstants.PROMPT_PASSPHRASE,identity.getName()))) {
throw new AuthCancelException("String_Node_Str");
}
if (_userinfo.getPassphrase() != null) {
passphrase=Util.str2byte(_userinfo.getPassphrase());
}
}
if ((!identity.isEncrypted() || passphrase != null) && identity.setPassphrase(passphrase)) {
break;
}
Util.bzero(passphrase);
passphrase=null;
}
Util.bzero(passphrase);
passphrase=null;
if (identity.isEncrypted()) {
continue;
}
if (pubkeyblob == null) {
pubkeyblob=identity.getPublicKeyBlob();
}
if (pubkeyblob == null) {
continue;
}
_packet.reset();
_buffer.setOffSet(0);
_buffer.putByte(SSH_MSG_USERAUTH_REQUEST);
_buffer.putString(session.getUserName());
_buffer.putString(SSH_CONNECTION);
_buffer.putString(UserAuth.PUBLICKEY);
_buffer.putByte((byte)1);
_buffer.putString(identity.getAlgorithmName());
_buffer.putString(pubkeyblob);
byte[] sid=session.getSessionId();
byte[] tmpData=new byte[4 + sid.length + _buffer.getLength() - 5];
Buffer tmp=new Buffer(tmpData);
tmp.putString(sid);
tmp.putBytes(_buffer,5,_buffer.getLength() - 5);
byte[] signature=identity.getSignature(tmpData);
if (signature == null) {
break;
}
_buffer.putString(signature);
session.write(_packet);
boolean read_more=true;
while (read_more) {
switch (session.read(_buffer).getCommand() & 0xff) {
case SSH_MSG_USERAUTH_SUCCESS:
return true;
case SSH_MSG_USERAUTH_BANNER:
userAuthBanner();
break;
case SSH_MSG_USERAUTH_FAILURE:
userAuthFailure();
read_more=false;
}
}
}
}
return false;
}