Program: 85632
Project: 85632
Buggy source:
@Override public int receiveBytes(ByteBuffer buff){
  checkArgument(buff.position() == 0 && buff.capacity() >= BitcoinSerializer.BitcoinPacketHeader.HEADER_LENGTH + 4);
  try {
    boolean firstMessage=true;
    while (true) {
      if (largeReadBuffer != null) {
        checkState(firstMessage);
        int bytesToGet=Math.min(buff.remaining(),largeReadBuffer.length - largeReadBufferPos);
        buff.get(largeReadBuffer,largeReadBufferPos,bytesToGet);
        largeReadBufferPos+=bytesToGet;
        if (largeReadBufferPos == largeReadBuffer.length) {
          processMessage(serializer.deserializePayload(header,ByteBuffer.wrap(largeReadBuffer)));
          largeReadBuffer=null;
          header=null;
        }
 else         return buff.position();
      }
      Message message;
      int preSerializePosition=buff.position();
      try {
        message=serializer.deserialize(buff);
      }
 catch (      BufferUnderflowException e) {
        if (firstMessage && buff.limit() == buff.capacity()) {
          buff.position(0);
          try {
            serializer.seekPastMagicBytes(buff);
            header=serializer.deserializeHeader(buff);
            largeReadBuffer=new byte[header.size];
            largeReadBufferPos=buff.remaining();
            buff.get(largeReadBuffer,0,largeReadBufferPos);
          }
 catch (          BufferUnderflowException e1) {
            throw new ProtocolException("String_Node_Str" + buff.capacity() + "String_Node_Str");
          }
        }
 else {
          buff.position(preSerializePosition);
        }
        return buff.position();
      }
      processMessage(message);
      firstMessage=false;
    }
  }
 catch (  Exception e) {
    exceptionCaught(e);
    return -1;
  }
}

Fixed version (ground truth):
@Override public int receiveBytes(ByteBuffer buff){
  checkArgument(buff.position() == 0 && buff.capacity() >= BitcoinSerializer.BitcoinPacketHeader.HEADER_LENGTH + 4);
  try {
    boolean firstMessage=true;
    while (true) {
      if (largeReadBuffer != null) {
        checkState(firstMessage);
        int bytesToGet=Math.min(buff.remaining(),largeReadBuffer.length - largeReadBufferPos);
        buff.get(largeReadBuffer,largeReadBufferPos,bytesToGet);
        largeReadBufferPos+=bytesToGet;
        if (largeReadBufferPos == largeReadBuffer.length) {
          processMessage(serializer.deserializePayload(header,ByteBuffer.wrap(largeReadBuffer)));
          largeReadBuffer=null;
          header=null;
          firstMessage=false;
        }
 else         return buff.position();
      }
      Message message;
      int preSerializePosition=buff.position();
      try {
        message=serializer.deserialize(buff);
      }
 catch (      BufferUnderflowException e) {
        if (firstMessage && buff.limit() == buff.capacity()) {
          buff.position(0);
          try {
            serializer.seekPastMagicBytes(buff);
            header=serializer.deserializeHeader(buff);
            largeReadBuffer=new byte[header.size];
            largeReadBufferPos=buff.remaining();
            buff.get(largeReadBuffer,0,largeReadBufferPos);
          }
 catch (          BufferUnderflowException e1) {
            throw new ProtocolException("String_Node_Str" + buff.capacity() + "String_Node_Str");
          }
        }
 else {
          buff.position(preSerializePosition);
        }
        return buff.position();
      }
      processMessage(message);
      firstMessage=false;
    }
  }
 catch (  Exception e) {
    exceptionCaught(e);
    return -1;
  }
}