chiark / gitweb /
WIP DNS bugfixes and debugging
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Aug 2011 13:44:59 +0000 (14:44 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 27 Aug 2011 15:44:05 +0000 (16:44 +0100)
dns-transp-common.c

index eb7d7cbc4c8a636f0f807e416b327407b9d77ced..f0c56fb6fe75d6a7d427564e48551a39097f6b3f 100644 (file)
@@ -7,7 +7,7 @@
 static const char out_table[32]="0123456789abcdefghijklmnopqrstuv";
 
 static void dump_enc(struct dnsdomainenc *be, const char *what) {
-    printf("ENC p=%08"PRIx32"/%-2d o=[%d]|%02x %s\n",
+    printf("ENC p=%08"PRIx32"/%-2d o=[%02d]|%02x %s\n",
           be->pending, be->npending,
           (int)(be->out - be->bufstop), *be->out,
           what);
@@ -121,7 +121,7 @@ void dnsdomaindec_globalinit(void) {
 
 static void dump_dec(struct dnsdomaindec *bd, const char *what) {
     int remain=bd->in - bd->databuf;
-    printf("DEC4 i=[%d]|%02x p=%08"PRIx32"/%-2d %s\n",
+    printf("DEC4 i=[%02d]|%02x p=%08"PRIx32"/%-2d %s\n",
           remain, remain ? *(bd->in-1) : 0,
           bd->pending, bd->npending,
           what);
@@ -152,7 +152,7 @@ int dnsdomaindec_start(struct dnsdomaindec *bd, const uint8_t *packet,
     for (;;) {
        if (domain==endpacket)
            return RCODE_FORMERR;
-       printf("DEC1 dom=|%d|%02x[%d]\n", domain-packet,
+       printf("DEC1 dom=|[%02d]|%02x[%02d]\n", domain-packet,
               *domain, endpacket-domain);
        unsigned b=*domain++;
        if (!b) {
@@ -222,8 +222,7 @@ static void inputchar(struct dnsdomaindec *bd) {
     /* must be enough input and enough space in pending */
     dump_dec(bd,"inputchar 1");
     int ch=*--(bd->in);
-    bd->pending <<= 8;
-    bd->pending |= ch; /* already decoded */
+    bd->pending |= (ch << bd->npending); /* already decoded */
     bd->npending += 5;
     dump_dec(bd,"inputchar 2");
 }