]> Cypherpunks.ru repositories - pyderasn.git/blobdiff - pyderasn.py
Fix double encoded values decoding in SET
[pyderasn.git] / pyderasn.py
index 43475f19fbdb486580b6c198a1a629698be8b90b..4cabec726c6a2c14f12a242fd326355f3334ee56 100755 (executable)
@@ -808,7 +808,7 @@ except ImportError:  # pragma: no cover
     def colored(what, *args, **kwargs):
         return what
 
-__version__ = "6.3"
+__version__ = "7.0"
 
 __all__ = (
     "Any",
@@ -5641,9 +5641,6 @@ class Set(Sequence):
         v = b"".join(raws)
         return b"".join((self.tag, len_encode(len(v)), v))
 
-    def _specs_items(self):
-        return iteritems(self.specs)
-
     def _decode(self, tlv, offset, decode_path, ctx, tag_only):
         try:
             t, tlen, lv = tag_strip(tlv)
@@ -5698,11 +5695,12 @@ class Set(Sequence):
         ctx_allow_default_values = ctx.get("allow_default_values", False)
         ctx_allow_unordered_set = ctx.get("allow_unordered_set", False)
         value_prev = memoryview(v[:0])
+        _specs_items = copy(self.specs)
 
         while len(v) > 0:
             if lenindef and v[:EOC_LEN].tobytes() == EOC:
                 break
-            for name, spec in self._specs_items():
+            for name, spec in iteritems(_specs_items):
                 sub_decode_path = decode_path + (name,)
                 try:
                     spec.decode(
@@ -5754,10 +5752,12 @@ class Set(Sequence):
                     offset=sub_offset,
                 )
             values[name] = value
+            del _specs_items[name]
             value_prev = v[:value_len]
             sub_offset += value_len
             vlen += value_len
             v = v_tail
+
         obj = self.__class__(
             schema=self.specs,
             impl=self.tag,