Skip to content

Commit 5274377

Browse files
author
phyber
committed
Properly handle exceptions in read_file
1 parent 5a90c26 commit 5274377

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tibudecrypt.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
from __future__ import print_function
1919
from __future__ import unicode_literals
2020

21-
import os
22-
import sys
2321
import base64
22+
import binascii
23+
import docopt
2424
import getpass
2525
import hashlib
2626
import hmac
27-
import docopt
27+
import os
2828
import six
29+
import sys
2930
import Crypto.Cipher.AES
3031
import Crypto.Cipher.PKCS1_v1_5
3132
import Crypto.PublicKey.RSA
@@ -162,7 +163,10 @@ def read_file(self):
162163
self.pass_hmac_result = base64.b64decode(pass_hmac_result)
163164
self.enc_privkey_spec = base64.b64decode(enc_privkey_spec)
164165
self.enc_sesskey_spec = base64.b64decode(enc_sesskey_spec)
165-
except:
166+
except binascii.Error:
167+
# Raised if the b64decode fails.
168+
raise
169+
except IOError:
166170
raise
167171

168172
def setup_crypto(self):

0 commit comments

Comments
 (0)