fix bug by adding null terminator
This commit is contained in:
parent
ed28de4e59
commit
ef3f2ae941
|
@ -1,3 +1,5 @@
|
||||||
|
// NOTE: this should be EXACTLY the same as PTR
|
||||||
|
|
||||||
(function (exports) {
|
(function (exports) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -8,8 +10,10 @@ exports.DNS_PACKER_TYPE_NS = function (ab, dv, total, record) {
|
||||||
throw new Error("no data on NS record");
|
throw new Error("no data on NS record");
|
||||||
}
|
}
|
||||||
|
|
||||||
var rdLenIndex = total;
|
// RDLENGTH
|
||||||
total +=2;
|
// leading len and length of string and trailing null (all dots become lengths)
|
||||||
|
dv.setUint16(total, record.data.length + 2, false);
|
||||||
|
total += 2;
|
||||||
|
|
||||||
// RDATA
|
// RDATA
|
||||||
// a sequence of labels
|
// a sequence of labels
|
||||||
|
@ -23,9 +27,8 @@ exports.DNS_PACKER_TYPE_NS = function (ab, dv, total, record) {
|
||||||
total += 1;
|
total += 1;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
dv.setUint8(total, 0x00, false);
|
||||||
// RDLENGTH
|
total += 1;
|
||||||
dv.setUint16(rdLenIndex, record.data.length + 1, false);
|
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// NOTE: this should be EXACTLY the same as NS
|
||||||
|
|
||||||
(function (exports) {
|
(function (exports) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -9,27 +11,25 @@ exports.DNS_PACKER_TYPE_PTR = function (ab, dv, total, record) {
|
||||||
throw new Error("no data for PTR record");
|
throw new Error("no data for PTR record");
|
||||||
}
|
}
|
||||||
|
|
||||||
var ptrLen = 0;
|
// RDLENGTH
|
||||||
var rdLenIndex = total;
|
// leading len and length of string and trailing null (all dots become lengths)
|
||||||
|
dv.setUint16(total, record.data.length + 2, false);
|
||||||
total += 2;
|
total += 2;
|
||||||
|
|
||||||
// RDATA
|
// RDATA
|
||||||
// a sequence of labels
|
// a sequence of labels
|
||||||
record.data.split('.').forEach(function (label){
|
record.data.split('.').forEach(function (label) {
|
||||||
console.log("the labels are: " + label);
|
|
||||||
ptrLen += 1 + label.length;
|
|
||||||
|
|
||||||
dv.setUint8(total, label.length, false);
|
dv.setUint8(total, label.length, false);
|
||||||
total += 1;
|
total += 1;
|
||||||
|
|
||||||
label.split('').forEach(function (ch){
|
label.split('').forEach(function (ch) {
|
||||||
dv.setUint8(total, ch.charCodeAt(0), false);
|
dv.setUint8(total, ch.charCodeAt(0), false);
|
||||||
total += 1;
|
total += 1;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
dv.setUint8(total, 0x00, false);
|
||||||
// RDLENGTH
|
total += 1;
|
||||||
dv.setUint16(rdLenIndex, record.data.length + 1, false);
|
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue