Buggy code:
public class Decoder { public static final AttributeKey < InetSocketAddress > INET_ADDRESS_KEY = AttributeKey . valueOf ( "inet-addr" ) ; public static final AttributeKey < PeerAddress > PEER_ADDRESS_KEY = AttributeKey . valueOf ( "peer-addr" ) ; private static final Logger LOG = LoggerFactory . getLogger ( Decoder . class ) ; private final Queue < Content > contentTypes = new LinkedList < Message . Content > ( ) ; private Message message = null ; private Signature signature = null ; private int neighborSize = - 1 ; private NeighborSet neighborSet = null ; private int peerSocketAddressSize = - 1 ; private List < PeerSocketAddress > peerSocketAddresses = null ; private int keyCollectionSize = - 1 ; private KeyCollection keyCollection = null ; private int mapSize = - 1 ; private DataMap dataMap = null ; private Data data = null ; private Number640 key = null ; private int keyMap640KeysSize = - 1 ; private KeyMap640Keys keyMap640Keys = null ; private int keyMapByteSize = - 1 ; private KeyMapByte keyMapByte = null ; private int bufferSize = - 1 ; private DataBuffer buffer = null ; private int trackerDataSize = - 1 ; private TrackerData trackerData = null ; private Data currentTrackerData = null ; private Content lastContent = null ; private final SignatureFactory signatureFactory ; public Decoder ( SignatureFactory signatureFactory ) { } public boolean decode ( ChannelHandlerContext ctx , final ByteBuf buf , InetSocketAddress recipient , final InetSocketAddress sender ) { } public void decodeSignature ( final ByteBuf buf , final int readerBefore , final boolean donePayload ) throws InvalidKeyException , SignatureException { } private void verifySignature ( final ByteBuf buf , final int readerBefore , final int len , final boolean donePayload ) throws InvalidKeyException , SignatureException { if ( ! ( message . isSign ( ) ) ) { return ; } <START_BUG> final int length = ( donePayload ) ? len - ( ( Number160 . BYTE_ARRAY_SIZE ) + ( Number160 . BYTE_ARRAY_SIZE ) ) : len ; <END_BUG> ByteBuffer [ ] byteBuffers = buf . nioBuffers ( readerBefore , length ) ; if ( ( signature ) == null ) { signature = signatureFactory . update ( message . publicKey ( 0 ) , byteBuffers ) ; } else { for ( int i = 0 ; i < ( byteBuffers . length ) ; i ++ ) { signature . update ( byteBuffers [ i ] ) ; } } if ( donePayload ) { byte [ ] signatureReceived = message . receivedSignature ( ) . encode ( ) ; Decoder . LOG . debug ( "Verifying<seq2seq4repair_space>received<seq2seq4repair_space>signature:<seq2seq4repair_space>{}" , Arrays . toString ( signatureReceived ) ) ; if ( signature . verify ( signatureReceived ) ) { message . setVerified ( ) ; Decoder . LOG . debug ( "Signature<seq2seq4repair_space>check<seq2seq4repair_space>OK." ) ; } else { Decoder . LOG . warn ( "Signature<seq2seq4repair_space>check<seq2seq4repair_space>NOT<seq2seq4repair_space>OK.<seq2seq4repair_space>Message:<seq2seq4repair_space>{}." , message ) ; } } } public boolean decodeHeader ( final ByteBuf buf , InetSocketAddress recipient , final InetSocketAddress sender ) { } public boolean decodePayload ( final ByteBuf buf ) throws InvalidKeyException , NoSuchAlgorithmException , InvalidKeySpecException { } public Message prepareFinish ( ) { } public Message message ( ) { } public Content lastContent ( ) { } public static void inheritPublicKey ( Message message , Data data ) { } }

Fix:
final int length = ( donePayload ) ? len - ( signatureFactory . signatureSize ( ) ) : len ;