Buggy code:
public class Transport { private final int blockSize = 4096 - 2 ; private Socket serverSocket ; private BufferedInputStream reader ; private OutputStream writer ; private KeyPair identity ; private PublicKey serverIdentity ; public byte [ ] peer ; private byte [ ] writeKey = new byte [ 32 ] ; private byte [ ] readKey = new byte [ 32 ] ; private SecretBox writeBox ; private SecretBox readBox ; private boolean writeKeyValid ; private boolean readKeyValid ; private byte [ ] writeSequence = new byte [ 24 ] ; private byte [ ] readSequence = new byte [ 24 ] ; private byte [ ] readBuffer ; private byte [ ] decryptBuffer ; private byte [ ] readPending ; private byte [ ] writeBuffer ; private KeyPair ephemeralKeyPair ; private byte [ ] ephemeralShared = new byte [ 32 ] ; private byte [ ] serverKeysMagic ; private byte [ ] clientKeysMagic ; private byte [ ] serverProofMagic ; private byte [ ] clientProofMagic ; private String address = "zkpp.obscure.systems" ; private String torAddress = "hv2pzxsx2drsyckk.onion" ; private String shortMessageError = "transport:<seq2seq4repair_space>received<seq2seq4repair_space>short<seq2seq4repair_space>handshake<seq2seq4repair_space>message" ; public Transport ( KeyPair i , PublicKey server ) { } private byte [ ] createMagic ( byte [ ] string ) { } public int Write ( byte [ ] buf ) throws IOException { } public int Read ( byte [ ] out ) throws IOException { <START_BUG> if ( ( ( readPending ) == null ) || ( ( readPending . length ) > 0 ) ) { <END_BUG> out = Arrays . copyOf ( readPending , out . length ) ; readPending = Arrays . copyOfRange ( readPending , out . length , readPending . length ) ; return out . length ; } if ( ( readBuffer ) == null ) readBuffer = new byte [ ( blockSize ) + 2 ] ; ByteStreams . readFully ( reader , readBuffer , 0 , 2 ) ; int n = ( ( int ) ( readBuffer [ 0 ] ) ) | ( ( ( int ) ( readBuffer [ 1 ] ) ) << 8 ) ; if ( n > ( readBuffer . length ) ) throw new IOException ( "transport:<seq2seq4repair_space>peer's<seq2seq4repair_space>message<seq2seq4repair_space>too<seq2seq4repair_space>large<seq2seq4repair_space>for<seq2seq4repair_space>Read" ) ; ByteStreams . readFully ( reader , readBuffer , 0 , n ) ; try { if ( ( out . length ) >= ( n - ( Globals . SECRETBOX_OVERHEAD ) ) ) { out = readBox . decrypt ( readSequence , readBuffer ) ; n = out . length ; } else { decryptBuffer = readBox . decrypt ( readSequence , readBuffer ) ; out = Arrays . copyOf ( decryptBuffer , n ) ; n = out . length ; readPending = Arrays . copyOfRange ( decryptBuffer , n , decryptBuffer . length ) ; } } catch ( RuntimeException e ) { readPending = new byte [ 0 ] ; throw new IOException ( "transport:<seq2seq4repair_space>bad<seq2seq4repair_space>MAC" ) ; } incSequence ( readSequence ) ; return n ; } public void writeProto ( Message . Builder message ) throws IOException { } public Reply readProto ( ) throws IOException { } public void Close ( ) { } private int write ( byte [ ] data ) { } private byte [ ] read ( byte [ ] data ) { } public byte readByte ( ) throws IOException { } private byte [ ] encrypt ( byte [ ] data ) { } private byte [ ] decrypt ( byte [ ] data ) { } private void setUpKeys ( byte [ ] ephemeralShared ) { } public void handshake ( ) throws IOException { } private byte [ ] incSequence ( byte [ ] seq ) { } private void printBytes ( byte [ ] b ) { } }

Fix:
if ( ( ( readPending ) != null ) || ( ( readPending . length ) > 0 ) ) {