From 074d9726278ab74ed669a98c4091c003dd45b219 Mon Sep 17 00:00:00 2001 From: Tom Hirst Date: Tue, 6 Aug 2019 09:44:47 +0100 Subject: [PATCH 1/2] Handle 0 length buffer in LocalFromBER function This internal function was assigning the error string to this.error, rather than returnObject.error, causing an exception. --- src/asn1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/asn1.js b/src/asn1.js index bdf7ca9..797b197 100644 --- a/src/asn1.js +++ b/src/asn1.js @@ -5301,7 +5301,7 @@ function LocalFromBER(inputBuffer, inputOffset, inputLength) //region Initial checks if(intBuffer.length === 0) { - this.error = "Zero buffer length"; + returnObject.error = "Zero buffer length"; return { offset: (-1), result: returnObject From 2dce1abb817a65946419931a01780dc647ca87d3 Mon Sep 17 00:00:00 2001 From: Tom Hirst Date: Tue, 6 Aug 2019 09:47:04 +0100 Subject: [PATCH 2/2] Fix default case in LocalFromBER The default case block was decoding the data, which then happens again after the case statement, causing a double read from the buffer (and then a subsequent crash) --- src/asn1.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/asn1.js b/src/asn1.js index 797b197..25605fb 100644 --- a/src/asn1.js +++ b/src/asn1.js @@ -5560,8 +5560,6 @@ function LocalFromBER(inputBuffer, inputOffset, inputLength) newObject.warnings = returnObject.warnings; returnObject = newObject; - - resultOffset = returnObject.fromBER(inputBuffer, inputOffset, inputLength); } //endregion }