[ECOS] 'id' rollover bug in dns.c

Will Lentz Will_Lentz@Trimble.com
Thu Oct 1 23:11:00 GMT 2009


Hi,
 
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;


Cheers,
Will

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list