fix buffer length bug
This commit is contained in:
parent
71960b48ce
commit
f804728831
2 changed files with 5 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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…
Reference in a new issue