Skip to content
Permalink
Browse files

Fix synchronization issues, remove weird/dead code

  • Loading branch information...
ibauersachs committed Oct 28, 2019
1 parent 19e5a12 commit 535300f2a11808f975ad9218fc4b39ea41ad16bf
@@ -677,7 +677,7 @@ public static String algString(int alg) throws UnsupportedAlgorithmException {
DNSInput in = new DNSInput(dns);
DNSOutput out = new DNSOutput();

int t = in.readU8();
/*int t =*/ in.readU8();

byte[] r = in.readByteArray(DSA_LEN);
int rlen = DSA_LEN;
@@ -737,7 +737,7 @@ public static String algString(int alg) throws UnsupportedAlgorithmException {
if (tmp != ASN1_SEQ) {
throw new IOException("Invalid ASN.1 data, expected " + ASN1_SEQ + " got " + tmp);
}
int seqlen = in.readU8();
/*int seqlen =*/ in.readU8();

tmp = in.readU8();
if (tmp != ASN1_INT) {
@@ -859,7 +859,7 @@ public static String algString(int alg) throws UnsupportedAlgorithmException {
if (tmp != ASN1_SEQ) {
throw new IOException("Invalid ASN.1 data, expected " + ASN1_SEQ + " got " + tmp);
}
int seqlen = in.readU8();
/*int seqlen =*/ in.readU8();

tmp = in.readU8();
if (tmp != ASN1_INT) {
@@ -17,30 +17,26 @@
private int flags;
private int[] counts;

private static Random random = new Random();
private static final Random random = new Random();

/** The length of a DNS Header in wire format. */
public static final int LENGTH = 12;

private void init() {
counts = new int[4];
flags = 0;
id = -1;
}

/**
* Create a new empty header.
*
* @param id The message id
*/
public Header(int id) {
init();
this();
setID(id);
}

/** Create a new empty header with a random message id */
public Header() {
init();
counts = new int[4];
flags = 0;
id = -1;
}

/** Parses a Header from a stream containing DNS wire format. */
@@ -90,9 +86,9 @@ static int setFlag(int flags, int bit, boolean value) {

// bits are indexed from left to right
if (value) {
return flags |= (1 << (15 - bit));
return flags | (1 << (15 - bit));
} else {
return flags &= ~(1 << (15 - bit));
return flags & ~(1 << (15 - bit));
}
}

@@ -139,10 +135,7 @@ public boolean getFlag(int bit) {

/** Retrieves the message ID */
public int getID() {
if (id >= 0) {
return id;
}
synchronized (this) {
synchronized (random) {
if (id < 0) {
id = random.nextInt(0xffff);
}
@@ -355,7 +355,7 @@ public void setCache(Cache cache) {
*
* @param ndots The ndots value to use, which must be greater than or equal to 0.
*/
public void setNdots(int ndots) {
public static void setNdots(int ndots) {
if (ndots < 0) {
throw new IllegalArgumentException("Illegal ndots value: " + ndots);
}
@@ -41,7 +41,7 @@
new Runnable() {
@Override
public void run() {
int n = prng.nextInt();
/*int n =*/ prng.nextInt();
prng_initializing = false;
}
})
@@ -173,7 +173,9 @@ public Zone(Name zone, Record[] records) throws IOException {
}

private void fromXFR(ZoneTransferIn xfrin) throws IOException, ZoneTransferException {
data = new TreeMap<>();
synchronized (this) {
data = new TreeMap<>();
}

origin = xfrin.getName();
List records = xfrin.run();
@@ -38,6 +38,9 @@ public static void main(String[] args) throws Exception {
case "xfrin":
xfrin.main(programArgs);
break;
default:
System.out.println("invalid command");
break;
}
}
}
@@ -443,8 +443,6 @@ byte addAnswer(Message response, Name name, int type, int dclass, int iterations
}

OPTRecord queryOPT = query.getOPT();
if (queryOPT != null && queryOPT.getVersion() > 0) {}

if (s != null) {
maxLength = 65535;
} else if (queryOPT != null) {
@@ -689,6 +689,6 @@ public static void main(String[] args) {
} else {
in = System.in;
}
update u = new update(in);
new update(in);
}
}

0 comments on commit 535300f

Please sign in to comment.
You can’t perform that action at this time.