From c2204e13e60f514e2fafe601959ec4ea444d5c20 Mon Sep 17 00:00:00 2001 From: elie Date: Fri, 24 Apr 2015 18:36:40 +0000 Subject: fix to broken REAL type decoding handling --- CHANGES | 5 +++-- pyasn1/codec/ber/decoder.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index ef13d0d..3ccae94 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,5 @@ -Revision 0.1.8 --------------- +Revision 0.1.8rc2 +----------------- - ObjectIdentifier codec fixed to work properly with arc 0 and arc 2 values. - Explicit limit on ObjectIdentifier arc value size removed. @@ -51,6 +51,7 @@ Revision 0.1.8 - Encoding bases 8 and 16 support for REAL type binary encoder added. - Fix to REAL type binary decoder to handle different bases and scale factor. - Fix to TagSet.repr() to include [obsolete] baseTag information. +- Fix to broken REAL type decoding handling. Revision 0.1.7 -------------- diff --git a/pyasn1/codec/ber/decoder.py b/pyasn1/codec/ber/decoder.py index 28a666d..7bb09ea 100644 --- a/pyasn1/codec/ber/decoder.py +++ b/pyasn1/codec/ber/decoder.py @@ -264,7 +264,9 @@ class RealDecoder(AbstractSimpleDecoder): if not head: return self._createComponent(asn1Spec, tagSet, 0.0), tail fo = oct2int(head[0]); head = head[1:] - if fo & 0x80: # binary enoding + if fo & 0x80: # binary encoding + if not head: + raise error.PyAsn1Error("Incomplete floating-point value") n = (fo & 0x03) + 1 if n == 4: n = oct2int(head[0]) @@ -297,6 +299,8 @@ class RealDecoder(AbstractSimpleDecoder): elif fo & 0x40: # infinite value value = fo & 0x01 and '-inf' or 'inf' elif fo & 0xc0 == 0: # character encoding + if not head: + raise error.PyAsn1Error("Incomplete floating-point value") try: if fo & 0x3 == 0x1: # NR1 value = (int(head), 10, 0) -- cgit v1.2.1