diff options
author | Jared Hobbs <jared@pyhacker.com> | 2019-03-20 10:08:12 -0600 |
---|---|---|
committer | Jared Hobbs <jared@pyhacker.com> | 2019-03-20 10:08:12 -0600 |
commit | 8d57be27ddeda68cbc0f97ee857871aadb5c5170 (patch) | |
tree | 42741b3fcd29f5bfda67b5933f3fa2566a8018f5 | |
parent | 242be1a5c978ed1ddeb4ab3b40e0cf5b1e97b9de (diff) |
handle exception that can occur if no regex match
-rw-r--r-- | paramiko/pkey.py | 4 |
1 files changed, 2 insertions, 2 deletions
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 |