From 25f29a82ccf3a411032a89cee111edd87f07ad3e Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 12 Feb 2020 12:50:22 +0300 Subject: [PATCH] Fix double encoded values decoding in SET --- VERSION | 2 +- doc/install.rst | 12 ++++++------ doc/news.rst | 7 +++++++ pyderasn.py | 10 +++++----- tests/test_pyderasn.py | 16 ++++++++++++++++ 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/VERSION b/VERSION index 0faee7d..4fedf1d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.3 +7.0 diff --git a/doc/install.rst b/doc/install.rst index 03d1116..a14ebc5 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -4,11 +4,11 @@ Install Preferable way is to :ref:`download ` tarball with the signature from `official website `__:: - $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-6.3.tar.xz - $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-6.3.tar.xz.sig - $ gpg --verify pyderasn-6.3.tar.xz.sig pyderasn-6.3.tar.xz - $ xz --decompress --stdout pyderasn-6.3.tar.xz | tar xf - - $ cd pyderasn-6.3 + $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-7.0.tar.xz + $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-7.0.tar.xz.sig + $ gpg --verify pyderasn-7.0.tar.xz.sig pyderasn-7.0.tar.xz + $ xz --decompress --stdout pyderasn-7.0.tar.xz | tar xf - + $ cd pyderasn-7.0 $ python setup.py install # or copy pyderasn.py (+six.py, possibly termcolor.py) to your PYTHONPATH @@ -19,7 +19,7 @@ You can also find it mirrored on :ref:`download ` page. You could use pip (**no** OpenPGP authentication is performed!) with PyPI:: $ cat > requirements.txt < 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, diff --git a/tests/test_pyderasn.py b/tests/test_pyderasn.py index 1cce9ed..3161102 100644 --- a/tests/test_pyderasn.py +++ b/tests/test_pyderasn.py @@ -6049,6 +6049,22 @@ class TestSet(SeqMixing, CommonMixin, TestCase): tags, ) + def test_same_value_twice(self): + class Seq(Set): + schema = ( + ("bool", Boolean()), + ("int", Integer()), + ) + + encoded = b"".join(( + Integer(123).encode(), + Integer(234).encode(), + Boolean(True).encode(), + )) + encoded = Seq.tag_default + len_encode(len(encoded)) + encoded + with self.assertRaises(TagMismatch): + Seq().decod(encoded, ctx={"allow_unordered_set": True}) + @composite def seqof_values_strategy(draw, schema=None, do_expl=False): -- 2.44.0