[Pkg-javascript-commits] [node-asn1.js] 122/202: der: fix indefinite length decoding
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Apr 20 19:19:00 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-asn1.js.
commit ea2c900e726c2e8dd7772195c0e65f4e70b0d78c
Author: felix <felix at userspace.com.au>
Date: Mon Sep 14 17:57:31 2015 +0700
der: fix indefinite length decoding
---
lib/asn1/decoders/der.js | 6 ++++--
test/der-decode-test.js | 6 ++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/asn1/decoders/der.js b/lib/asn1/decoders/der.js
index cf878a7..7df8509 100644
--- a/lib/asn1/decoders/der.js
+++ b/lib/asn1/decoders/der.js
@@ -71,14 +71,16 @@ DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
// Indefinite length... find END tag
- var state = buffer.start();
+ var state = buffer.save();
var res = this._skipUntilEnd(
buffer,
'Failed to skip indefinite length body: "' + this.tag + '"');
if (buffer.isError(res))
return res;
- return buffer.cut(state);
+ len = buffer.offset - state.offset;
+ buffer.restore(state);
+ return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
};
DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
diff --git a/test/der-decode-test.js b/test/der-decode-test.js
index fa81b60..a43033b 100644
--- a/test/der-decode-test.js
+++ b/test/der-decode-test.js
@@ -69,4 +69,10 @@ describe('asn1.js DER decoder', function() {
var out = A.decode(new Buffer('020101', 'hex'), 'der');
assert.equal(out.toString(10), '1');
});
+
+ test('should decode indefinite length', function() {
+ this.seq().obj(
+ this.key('key').bool()
+ );
+ }, '30800101ff0000', { 'key': true });
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-asn1.js.git
More information about the Pkg-javascript-commits
mailing list