summaryrefslogtreecommitdiffstats
path: root/ipalib/parameters.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2015-10-06 13:54:33 +0200
committerMartin Basti <mbasti@redhat.com>2015-10-22 18:34:46 +0200
commiteab334dde8e3f94fcf1fca0d111b5121e26c1f4f (patch)
tree0e68560a9a7bfb89204bc78e34b7d95adc59fdc6 /ipalib/parameters.py
parent92a4b18fc282ab7b40899c4885617fc080e9e955 (diff)
downloadfreeipa-eab334dde8e3f94fcf1fca0d111b5121e26c1f4f.tar.gz
freeipa-eab334dde8e3f94fcf1fca0d111b5121e26c1f4f.tar.xz
freeipa-eab334dde8e3f94fcf1fca0d111b5121e26c1f4f.zip
Handle binascii.Error from base64.b64decode()
In Python 3, the base64.b64decode function raises binascii.Error (a ValueError subclass) when it finds incorrect padding. In Python 2 it raises TypeError. Callers should usually handle ValueError; unless they are specifically concerned with handling base64 padding issues). In some cases, callers should handle ValueError: - ipalib.pkcs10 (get_friendlyname, load_certificate_request): callers should handle ValueError - ipalib.x509 (load_certificate*, get_*): callers should handle ValueError In other cases ValueError is handled: - ipalib.parameters - ipapython.ssh - ipalib.rpc (json_decode_binary - callers already expect ValueError) - ipaserver.install.ldapupdate Elsewhere no error handling is done, because values come from trusted sources, or are pre-validated: - vault plugin - ipaserver.install.cainstance - ipaserver.install.certs - ipaserver.install.ipa_otptoken_import Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipalib/parameters.py')
-rw-r--r--ipalib/parameters.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index ef8814eeb..dadd87d6a 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -1383,7 +1383,7 @@ class Bytes(Data):
if isinstance(value, unicode):
try:
value = base64.b64decode(value)
- except TypeError as e:
+ except (TypeError, ValueError) as e:
raise Base64DecodeError(reason=str(e))
return super(Bytes, self)._convert_scalar(value, index)