diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2016-04-02 13:03:05 -0400 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-04-02 13:03:05 -0400 |
commit | 70153dd363e0cc12ef201ca4c1b2cef04dea6b5d (patch) | |
tree | adcb5f341b1f52ea54b2fed3c2dd353106482278 /src | |
parent | 15ab4fc371bc9f94868f430eec9d55bca05e147a (diff) | |
download | cryptography-70153dd363e0cc12ef201ca4c1b2cef04dea6b5d.tar.gz cryptography-70153dd363e0cc12ef201ca4c1b2cef04dea6b5d.tar.bz2 cryptography-70153dd363e0cc12ef201ca4c1b2cef04dea6b5d.zip |
Handle two more error conditions correctly
* Handle two more error conditions correctly
* fixed test case
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/primitives/serialization.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/primitives/serialization.py b/src/cryptography/hazmat/primitives/serialization.py index 5c166c89..d848e5d4 100644 --- a/src/cryptography/hazmat/primitives/serialization.py +++ b/src/cryptography/hazmat/primitives/serialization.py @@ -127,7 +127,13 @@ def _read_next_string(data): While the RFC calls these strings, in Python they are bytes objects. """ + if len(data) < 4: + raise ValueError("Key is not in the proper format") + str_len, = struct.unpack('>I', data[:4]) + if len(data) < str_len + 4: + raise ValueError("Key is not in the proper format") + return data[4:4 + str_len], data[4 + str_len:] |