]> Cypherpunks.ru repositories - pyderasn.git/blobdiff - pyderasn.py
Fix SequenceOf/SetOf BoundsError raising
[pyderasn.git] / pyderasn.py
index b9bc9dae515564a24dcc052005754d54993fca03..38b05484720648f7d5242db4f7ade865a85cbd1a 100755 (executable)
@@ -5025,16 +5025,24 @@ class SequenceOf(Obj):
             vlen += value_len
             v = v_tail
             _value.append(value)
-        obj = self.__class__(
-            value=_value,
-            schema=spec,
-            bounds=(self._bound_min, self._bound_max),
-            impl=self.tag,
-            expl=self._expl,
-            default=self.default,
-            optional=self.optional,
-            _decoded=(offset, llen, vlen + (EOC_LEN if lenindef else 0)),
-        )
+        try:
+            obj = self.__class__(
+                value=_value,
+                schema=spec,
+                bounds=(self._bound_min, self._bound_max),
+                impl=self.tag,
+                expl=self._expl,
+                default=self.default,
+                optional=self.optional,
+                _decoded=(offset, llen, vlen + (EOC_LEN if lenindef else 0)),
+            )
+        except BoundsError as err:
+            raise DecodeError(
+                msg=str(err),
+                klass=self.__class__,
+                decode_path=decode_path,
+                offset=offset,
+            )
         if lenindef:
             if v[:EOC_LEN].tobytes() != EOC:
                 raise DecodeError(