Browse Source

fix buffer length bug

master
AJ ONeal 5 years ago
parent
commit
f804728831
  1. 3
      bin/rasha.js
  2. 4
      lib/uasn1.js

3
bin/rasha.js

@ -71,5 +71,6 @@ function write(asn1) {
ws = ws.slice(1);
});
}
console.log(asn1);
console.log(JSON.stringify(asn1, null, 2));
//console.log(asn1);
write(asn1);

4
lib/uasn1.js

@ -29,6 +29,7 @@ ASN1.parse = function parseAsn1(buf, depth) {
// this is a primitive value type
if (-1 !== VTYPES.indexOf(asn1.type)) {
//console.log('t', asn1.type);
asn1.value = buf.slice(index, index + asn1.length);
return asn1;
}
@ -36,8 +37,9 @@ ASN1.parse = function parseAsn1(buf, depth) {
asn1.children = [];
while (iters < 100 && index < buf.byteLength) {
iters += 1;
child = ASN1.parse(buf.slice(index), (depth || 0) + 1);
child = ASN1.parse(buf.slice(index, index + asn1.length), (depth || 0) + 1);
index += (2 + child.lengthSize + child.length);
//console.log('buflen', buf.byteLength, 'index', index);
asn1.children.push(child);
}
if (iters >= 100) { throw new Error(ELOOP); }

Loading…
Cancel
Save