Buggy code:
public class SimpleResolver implements Resolver { public static final int DEFAULT_PORT = 53 ; private InetAddress addr ; private int port = SimpleResolver . DEFAULT_PORT ; private boolean useTCP ; private boolean ignoreTruncation ; private byte EDNSlevel = - 1 ; private TSIG tsig ; private int timeoutValue = 10 * 1000 ; private static final short DEFAULT_UDPSIZE = 512 ; private static final short EDNS_UDPSIZE = 1280 ; private static String defaultResolver = "localhost" ; private static int uniqueID = 0 ; public SimpleResolver ( String hostname ) throws UnknownHostException { } public SimpleResolver ( ) throws UnknownHostException { } public static void setDefaultResolver ( String hostname ) { } public void setPort ( int port ) { } public void setTCP ( boolean flag ) { } public void setIgnoreTruncation ( boolean flag ) { } public void setEDNS ( int level ) { } public void setTSIGKey ( Name name , byte [ ] key ) { } public void setTSIGKey ( String name , String key ) { } public void setTSIGKey ( String key ) throws UnknownHostException { } public void setTimeout ( int secs ) { } private byte [ ] readUDP ( DatagramSocket s , int max ) throws IOException { } private void writeUDP ( DatagramSocket s , byte [ ] out , InetAddress addr , int port ) throws IOException { } private byte [ ] readTCP ( Socket s ) throws IOException { } private void writeTCP ( Socket s , byte [ ] out ) throws IOException { } private Message parseMessage ( byte [ ] b ) throws WireParseException { } private void verifyTSIG ( Message query , Message response , byte [ ] b , TSIG tsig ) { } private void applyEDNS ( Message query ) { } private int maxUDPSize ( Message query ) { } public Message send ( Message query ) throws IOException { } public Object sendAsync ( final Message query , final ResolverListener listener ) { } private Message sendAXFR ( Message query ) throws IOException { Socket s = new Socket ( addr , port ) ; s . setSoTimeout ( timeoutValue ) ; try { query = ( ( Message ) ( query . clone ( ) ) ) ; if ( ( tsig ) != null ) tsig . apply ( query , null ) ; byte [ ] out = query . toWire ( MAXLENGTH ) ; writeTCP ( s , out ) ; byte [ ] in = readTCP ( s ) ; Message response = parseMessage ( in ) ; if ( ( response . getHeader ( ) . getRcode ( ) ) != ( Rcode . NOERROR ) ) return response ; if ( ( tsig ) != null ) { tsig . verifyAXFRStart ( ) ; verifyTSIG ( query , response , in , tsig ) ; } int soacount = 0 ; Record [ ] records = response . getSectionArray ( ANSWER ) ; for ( int i = 0 ; i < ( records . length ) ; i ++ ) if ( ( records [ i ] ) instanceof SOARecord ) soacount ++ ; while ( soacount < 2 ) { in = readTCP ( s ) ; Message m = parseMessage ( in ) ; short rcode = m . getHeader ( ) . getRcode ( ) ; if ( rcode != ( Rcode . NOERROR ) ) throw new WireParseException ( ( "AXFR:<seq2seq4repair_space>rcode<seq2seq4repair_space>" + ( Rcode . string ( rcode ) ) ) ) ; Header header = m . getHeader ( ) ; if ( ( ( ( header . getCount ( QUESTION ) ) > 1 ) || ( ( header . getCount ( ANSWER ) ) <= 0 ) ) || ( ( header . getCount ( AUTHORITY ) ) != 0 ) ) { if ( Options . check ( "verbosemsg" ) ) System . err . println ( m ) ; throw new WireParseException ( "AXFR:<seq2seq4repair_space>invalid<seq2seq4repair_space>record<seq2seq4repair_space>counts" ) ; } records = m . getSectionArray ( ANSWER ) ; for ( int i = 0 ; i < ( records . length ) ; i ++ ) { response . addRecord ( records [ i ] , ANSWER ) ; if ( ( records [ i ] ) instanceof SOARecord ) soacount ++ ; } if ( soacount > 2 ) throw new WireParseException ( "AXFR:<seq2seq4repair_space>too<seq2seq4repair_space>many<seq2seq4repair_space>SOAs" ) ; if ( ( tsig ) == null ) continue ; <START_BUG> byte error = tsig . verifyAXFR ( m , in , query . getTSIG ( ) , ( soacount > 1 ) , false ) ; <END_BUG> if ( error != ( Rcode . NOERROR ) ) response . TSIGverified = false ; if ( Options . check ( "verbose" ) ) System . err . println ( ( "TSIG<seq2seq4repair_space>verify:<seq2seq4repair_space>" + ( Rcode . string ( error ) ) ) ) ; } return response ; } finally { s . close ( ) ; } } }

Fix:
byte error = tsig . verifyAXFR ( m , in , null , ( soacount > 1 ) , false ) ;