This is the mail archive of the ecos-bugs@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Issue 1000835] New: 'id' rollover bug in dns.c


http://bugzilla.ecoscentric.com/show_bug.cgi?id=1000835

           Summary: 'id' rollover bug in dns.c
           Product: eCos
           Version: CVS
          Platform: All
        OS/Version: HostOS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: normal
         Component: TCP/IP
        AssignedTo: gary@mlbassoc.com
        ReportedBy: will_lentz@trimble.com
         QAContact: ecos-bugs@ecos.sourceware.org
             Class: Advice Request


There is a rollover bug in the current CVS copy of dns.c. Around line 237 there
is the following code:
            /* Reply to an old query. Ignore it */
            if (ntohs(dns_hdr->id) != (id-1)) {

If dns_hdr->id == 5 and id == 6, then the 'if' condition is false as expected.

If dns_hdr->id == 0xFFFF and id == 0, then the 'if' condition is incorrectly
true.

The simple patch below fixes the issue:
--- dns_old.c   2009-10-01 16:01:41.000000000 -0700
+++ dns.c       2009-10-01 16:01:45.000000000 -0700
@@ -234,7 +234,7 @@
             }

             /* Reply to an old query. Ignore it */
-            if (ntohs(dns_hdr->id) != (id-1)) {
+            if (ntohs(dns_hdr->id) != (cyg_uint16)(id-1)) {
                 continue;
             }
             finished = true;

Jay Foster also suggested the following change which fixes the issue:
-----------------------
Then declare a new variable in send_recv()

     unsigned short req_id;

Then assign this variable with the ID value contained in the DNS request

     dns_hdr = (struct dns_header *) &msg_buf[0];
+    req_id = ((struct dns_header *)msg)->id;
     do {
         /* Send a request to each configured DNS server */

Then compare the ID in the responses with req_id

                 if (dns_hdr->id != req_id) {
                     continue;
                 }
-----------------------
Either method fixes the problem...


-- 
Configure issuemail: http://bugzilla.ecoscentric.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the issue.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]