From 33333da28383024d7d9f8fedc351f62874f623a3 Mon Sep 17 00:00:00 2001 From: patrik Date: Thu, 20 Oct 2011 02:44:20 +0000 Subject: [PATCH] Added a new function setStopOnError to the ASN1 library. The function allows the library to be set to a mode that will stop trying to decode a ASN1 structure as soon as it runs into a decoding error. [Patrik] --- nselib/asn1.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nselib/asn1.lua b/nselib/asn1.lua index 45780c53e..c7563de2a 100644 --- a/nselib/asn1.lua +++ b/nselib/asn1.lua @@ -36,6 +36,16 @@ ASN1Decoder = { self.__index = self return o end, + + --- Tells the decoder to stop if it detects an error while decoding + -- this should probably be the default, but some scripts depend on being + -- able to decode stuff while lacking proper ASN1 decoding functions. + -- + -- @param val boolean, true if decoding should stop on error, + -- otherwise false (default) + setStopOnError = function(self, val) + self.stoponerror = val + end, --- Registers the base simple type decoders -- @@ -150,6 +160,7 @@ ASN1Decoder = { while (sPos < len) do local newSeq sPos, newSeq = self:decode(sStr, sPos) + if ( not(newSeq) and self.stoponerror ) then break end table.insert(seq, newSeq) end return pos, seq