22 lines
713 B
Diff
22 lines
713 B
Diff
|
commit 8d57be27ddeda68cbc0f97ee857871aadb5c5170
|
||
|
Author: Jared Hobbs <jared@pyhacker.com>
|
||
|
Date: Wed Mar 20 10:08:12 2019 -0600
|
||
|
|
||
|
handle exception that can occur if no regex match
|
||
|
|
||
|
diff --git a/paramiko/pkey.py b/paramiko/pkey.py
|
||
|
index f2447e15..0464795a 100644
|
||
|
--- a/paramiko/pkey.py
|
||
|
+++ b/paramiko/pkey.py
|
||
|
@@ -307,8 +307,8 @@ class PKey(object):
|
||
|
start += 1
|
||
|
m = self.BEGIN_TAG.match(lines[start])
|
||
|
start += 1
|
||
|
- keytype = m.group(1)
|
||
|
- if start >= len(lines):
|
||
|
+ keytype = m.group(1) if m else None
|
||
|
+ if start >= len(lines) or keytype is None:
|
||
|
raise SSHException("not a valid " + tag + " private key file")
|
||
|
|
||
|
# find the END tag
|