changeset 2514:d5dc1a185974

* src/dns.c: id global should be unsigned, in line with DNS header. * include/dns_impl.inl (build_query): Guarantee id in header is only 16-bits. Thanks to Frank Huang for the report.
author jlarmour
date Tue, 12 Aug 2008 16:52:02 +0000
parents 9454b98df9aa
children 24c0267fbb70
files packages/net/ns/dns/current/ChangeLog packages/net/ns/dns/current/include/dns_impl.inl packages/net/ns/dns/current/src/dns.c
diffstat 3 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/packages/net/ns/dns/current/ChangeLog
+++ b/packages/net/ns/dns/current/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-12  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* src/dns.c: id global should be unsigned, in line with DNS header.
+	* include/dns_impl.inl (build_query): Guarantee id in header is only
+	16-bits.
+	Thanks to Frank Huang for the report.
+
 2006-05-19  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* tests/dns1.c (dns_test_thread): Use CYG_NELEM from infra.
--- a/packages/net/ns/dns/current/include/dns_impl.inl
+++ b/packages/net/ns/dns/current/include/dns_impl.inl
@@ -199,7 +199,7 @@ build_query(const unsigned char * msg, c
 
     /* Fill out the header */
     dns_hdr = (struct dns_header *) msg;
-    dns_hdr->id = htons(id++);
+    dns_hdr->id = (cyg_uint16)htons(id++);
     dns_hdr->rd = true;
     dns_hdr->opcode = DNS_QUERY;
     dns_hdr->qdcount = htons(1);
--- a/packages/net/ns/dns/current/src/dns.c
+++ b/packages/net/ns/dns/current/src/dns.c
@@ -80,7 +80,7 @@
 
 #include <cyg/ns/dns/dns_priv.h>
 
-static short id = 0;              /* ID of the last query */
+static cyg_uint16 id = 0;         /* ID of the last query */
 static int s = -1;                /* Socket to the DNS server */
 static cyg_drv_mutex_t dns_mutex; /* Mutex to stop multiple queries as once */
 static cyg_ucount32 ptdindex;     /* Index for the per thread data */