Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7155051

DNS provider may return incorrect results

XMLWordPrintable

    • b34
    • generic
    • generic
    • Verified

        FULL PRODUCT VERSION :
        java version "1.6.0_24"
        Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
        Java HotSpot(TM) Server VM (build 19.1-b02, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        SunOS nms-cricket 5.10 Generic_141414-01 sun4u sparc SUNW,Sun-Fire-V210

        A DESCRIPTION OF THE PROBLEM :
        The DNS provider attempts to check the XID of the response to make sure the response received from the server matches the requested XID. If the response's XID does not match, the DNS provider caches the response in case another thread needs it. However, the response is cached with the incorrect XID. Therefore, when the lookup code continues, the current request receives an incorrect response.

        I have included a patch that will correct the problem.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Create a new JNDI context that uses the DNS provider. Attempt to do a a ctxt.getAttributes() using this context. If multiple threads are involved, the results from the lookup can be incorrect. This has a tendency to occur more frequently if the com.sun.jndi.dns.timeout.initial value is particularly low.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The expected result is to get the correct answer from the DNS lookup.
        ACTUAL -
        The lookup result may contain the answer from another query occurring from another thread.

        REPRODUCIBILITY :
        This bug can be reproduced occasionally.

        ---------- BEGIN SOURCE ----------
        This can be reproduced with the standard usage of JNDI DNS provider. I will include the diff that will correct this in the Workaround section.


        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        --- j2se/src/share/classes/com/sun/jndi/dns/DnsClient.java.orig 2011-08-20 14:06:55.000000000 -0400
        +++ j2se/src/share/classes/com/sun/jndi/dns/DnsClient.java 2011-08-20 14:07:13.000000000 -0400
        @@ -560,8 +560,8 @@ public class DnsClient {
                // enqueue only the first response, responses for retries are ignored.
                //
                 synchronized (queuesLock) {
        - if (reqs.contains(xid)) { // enqueue only the first response
        - resps.put(xid, pkt);
        + if (reqs.contains(hdr.xid)) { // enqueue only the first response
        + resps.put(hdr.xid, pkt);
                    }
                 }

              xuelei Xuelei Fan
              xuelei Xuelei Fan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: