From b2dd53dcb15a48074d6b9da24e4bab1660bce810 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 19 Oct 2017 12:53:56 -0600 Subject: [PATCH] terminate labels with null --- packer/type.cname.js | 18 ++++++++++-------- packer/type.mx.js | 2 +- packer/type.srv.js | 4 ++++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packer/type.cname.js b/packer/type.cname.js index afa823e..29d8711 100644 --- a/packer/type.cname.js +++ b/packer/type.cname.js @@ -15,20 +15,22 @@ exports.DNS_PACKER_TYPE_CNAME = function (ab, dv, total, record) { // RDATA // a sequence of labels record.data.split('.').forEach(function (label) { - cnameLen += 1 + label.length; - - dv.setUint8(total, label.length, false); - total += 1; + cnameLen += 1 + label.length; - label.split('').forEach(function (ch) { - dv.setUint8(total, ch.charCodeAt(0), false); + dv.setUint8(total, label.length, false); total += 1; + + label.split('').forEach(function (ch) { + dv.setUint8(total, ch.charCodeAt(0), false); + total += 1; }); }); + dv.setUint8(total, 0x00, false); + total += 1; // RDLENGTH - dv.setUint16(rdLenIndex, record.data.length + 1, false); - + dv.setUint16(rdLenIndex, record.data.length + 2, false); + return total; }; diff --git a/packer/type.mx.js b/packer/type.mx.js index 2b472c4..b434086 100644 --- a/packer/type.mx.js +++ b/packer/type.mx.js @@ -31,7 +31,7 @@ exports.DNS_PACKER_TYPE_MX = function (ab, dv, total, record) { total += 1; }); }); - dv.setUint8(total, 0, false); + dv.setUint8(total, 0x00, false); total += 1; mxLen += 1; diff --git a/packer/type.srv.js b/packer/type.srv.js index 063576f..cec8669 100644 --- a/packer/type.srv.js +++ b/packer/type.srv.js @@ -59,6 +59,10 @@ exports.DNS_PACKER_TYPE_SRV = function (ab, dv, total, record) { }); }); + dv.setUint8(total, 0x00, false); + total += 1; + srvLen += 1; + // RDLENGTH dv.setUint16(rdLenIndex, srvLen, false);