Mercurial > kallithea
changeset 8664:be839636b6e4
ssh: import binascii directly, instead of using it through base64 module
It is unfortunate that the base64 module is leaking its binascii internals in
exception types. We started using binascii through the base64 import in
08af13a090e0, but the import is not public, and pytype thus complains.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sat, 10 Oct 2020 13:11:13 +0200 |
parents | a3f649baa016 |
children | bbd96bdf8372 |
files | kallithea/lib/ssh.py |
diffstat | 1 files changed, 2 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/ssh.py Sat Oct 10 13:45:52 2020 +0200 +++ b/kallithea/lib/ssh.py Sat Oct 10 13:11:13 2020 +0200 @@ -22,6 +22,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import base64 +import binascii import logging import re import struct @@ -109,7 +110,7 @@ try: key_bytes = base64.b64decode(keyvalue) - except base64.binascii.Error: # Must be caused by truncation - either "Invalid padding" or "Invalid base64-encoded string: number of data characters (x) cannot be 1 more than a multiple of 4" + except binascii.Error: # Must be caused by truncation - either "Invalid padding" or "Invalid base64-encoded string: number of data characters (x) cannot be 1 more than a multiple of 4" raise SshKeyParseError(_("Invalid SSH key - base64 part %r seems truncated (it can't be decoded)") % keyvalue) # Check key internals to make sure the key wasn't truncated in a way that base64 can decode: