From 7f673f6fbf496d82aeb1c81e2701346940215e83 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 11 Feb 2017 09:54:27 -0700 Subject: [PATCH] only add compression pointer length once --- dns.parser.js | 6 ++---- dns.unpack-labels.js | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dns.parser.js b/dns.parser.js index 769b412..61014c0 100644 --- a/dns.parser.js +++ b/dns.parser.js @@ -106,9 +106,6 @@ pdns.unpack = function (ab) { q.className = classes[q.class]; q.typeName = types[q.type]; - // console.log('*********************'); - // console.log(q.typeName); - return q; } @@ -129,7 +126,7 @@ pdns.unpack = function (ab) { //, rdata: 0 , rdlength: 0 }); - //console.log('unpackAnswer QNAME:'); + //console.log('unpackAnswer [Q]NAME:'); //console.log(q); total += q.byteLength; q.className = classes[q.class]; @@ -171,6 +168,7 @@ pdns.unpack = function (ab) { total += q.rdlength; q.byteLength = total - ototal; + return q; } diff --git a/dns.unpack-labels.js b/dns.unpack-labels.js index 477b95e..ca791e2 100644 --- a/dns.unpack-labels.js +++ b/dns.unpack-labels.js @@ -34,8 +34,10 @@ exports.DNS_UNPACK_LABELS = function (ui8, ptr, q) { // we're not coming back! ptr = cpptr; + if (!q.cpcount) { + q.byteLength += 2; // cp and len + } q.cpcount += 1; - q.byteLength += 2; // cp and len // recursion return exports.DNS_UNPACK_LABELS(ui8, ptr, q);