From 286755cfbed07ad57f6f995d96464c106ef6fa4d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 1 Aug 2011 14:44:59 +0100 Subject: [PATCH] WIP DNS bugfixes and debugging --- dns-transp-common.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dns-transp-common.c b/dns-transp-common.c index eb7d7cb..f0c56fb 100644 --- a/dns-transp-common.c +++ b/dns-transp-common.c @@ -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"); } -- 2.30.2