Skip to content

Commit eac9de8

Browse files
committed
Fix GH#852: a PEM file must have at least 3 lines
1 parent 46bf040 commit eac9de8

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

Changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ New features
1111
Resolved issues
1212
---------------
1313
* GH#846: fix infinite loop with RC4 for data larger than 4GB.
14+
* GH#852: handle correctly invalid PEM files with less than 3 lines.
1415

1516
Other changes
1617
-------------

lib/Crypto/IO/PEM.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ def decode(pem_data, passphrase=None):
137137

138138
# Removes spaces and slit on lines
139139
lines = pem_data.replace(" ", '').split()
140+
if len(lines) < 3:
141+
raise ValueError("A PEM file must have at least 3 lines")
140142

141143
# Decrypts, if necessary
142144
if lines[1].startswith('Proc-Type:4,ENCRYPTED'):

0 commit comments

Comments
 (0)