On 02.03.2016 17:17, Martin Basti wrote:
Patch attached, read commit message for more info.


https://fedorahosted.org/freeipa/ticket/5718

Updated patch attached.
From a4d22716232dd7eaf39fa13df0f857d5d288d5ac Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Wed, 2 Mar 2016 17:13:27 +0100
Subject: [PATCH] fix suspicious except statements

The "except ValueError as UnicodeDecodeError" looks very suspicious.
Commit change except to catch both exceptions.

https://fedorahosted.org/freeipa/ticket/5718
---
 client/ipa-client-install | 2 +-
 ipalib/util.py            | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/client/ipa-client-install b/client/ipa-client-install
index 1e611244593b4db88beacfdeb47e92faae24132e..44ddeb956dfd6928317d50309aea42d8eb9e2de0 100755
--- a/client/ipa-client-install
+++ b/client/ipa-client-install
@@ -1798,7 +1798,7 @@ def update_ssh_keys(server, hostname, ssh_dir, create_sshfp):
                 continue
             try:
                 pubkey = SSHPublicKey(line)
-            except ValueError as UnicodeDecodeError:
+            except (ValueError, UnicodeDecodeError):
                 continue
             root_logger.info("Adding SSH public key from %s", filename)
             pubkeys.append(pubkey)
diff --git a/ipalib/util.py b/ipalib/util.py
index 6c70fbdfcb1f936468101dd2e5ed726ec614a893..262acf926e73ba1521faa151154e2149875be4b7 100644
--- a/ipalib/util.py
+++ b/ipalib/util.py
@@ -278,13 +278,13 @@ def normalize_sshpubkey(value):
 def validate_sshpubkey(ugettext, value):
     try:
         SSHPublicKey(value)
-    except ValueError as UnicodeDecodeError:
+    except (ValueError, UnicodeDecodeError):
         return _('invalid SSH public key')
 
 def validate_sshpubkey_no_options(ugettext, value):
     try:
         pubkey = SSHPublicKey(value)
-    except ValueError as UnicodeDecodeError:
+    except (ValueError, UnicodeDecodeError):
         return _('invalid SSH public key')
 
     if pubkey.has_options():
@@ -304,7 +304,7 @@ def convert_sshpubkey_post(ldap, dn, entry_attrs):
     for pubkey in pubkeys:
         try:
             pubkey = SSHPublicKey(pubkey)
-        except ValueError as UnicodeDecodeError:
+        except (ValueError, UnicodeDecodeError):
             continue
 
         fp = pubkey.fingerprint_hex_md5()
-- 
2.5.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to