From 3555f1d4267710e99b9df0755388b3a3f1e1e037 Mon Sep 17 00:00:00 2001 From: "kuldeep.k@cisinlabs.com" Date: Mon, 27 Sep 2021 19:10:39 +0530 Subject: [PATCH] Updated ValueError in addresses.py, updated safeGet & added exception handling for read permission error in helper_startup.py and reverted highlevelcrypto.py changes --- src/addresses.py | 2 +- src/helper_startup.py | 10 +++++++--- src/highlevelcrypto.py | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/addresses.py b/src/addresses.py index dd3580f6..560849df 100644 --- a/src/addresses.py +++ b/src/addresses.py @@ -45,7 +45,7 @@ def decodeBase58(string, alphabet=ALPHABET): for char in string: num *= base num += alphabet.index(char) - except: # noqa:E722 # ValueError + except ValueError: # character not found (like a space character or a 0) return 0 return num diff --git a/src/helper_startup.py b/src/helper_startup.py index 5c865f49..9fa4f261 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -49,13 +49,17 @@ def loadConfig(): 'Loading config files from directory specified' ' on startup: %s', state.appdata) else: - config.read(paths.lookupExeFolder() + 'keys.dat') try: - config.get('bitmessagesettings', 'settingsversion') + config.read(paths.lookupExeFolder() + 'keys.dat') + except: # noqa:E722 + logger.info( + 'Permission error in BMConfigParser().read() method for keys.dat file') + + if config.safeGet('bitmessagesettings', 'settingsversion'): logger.info('Loading config files from same directory as program.') needToCreateKeysFile = False state.appdata = paths.lookupExeFolder() - except: # noqa:E722 + else: # Could not load the keys.dat file in the program directory. # Perhaps it is in the appdata directory. state.appdata = paths.lookupAppdataFolder() diff --git a/src/highlevelcrypto.py b/src/highlevelcrypto.py index 431a6dae..82743acf 100644 --- a/src/highlevelcrypto.py +++ b/src/highlevelcrypto.py @@ -95,7 +95,7 @@ def verify(msg, sig, hexPubkey): # old SHA1 algorithm. sigVerifyPassed = makePubCryptor(hexPubkey).verify( sig, msg, digest_alg=OpenSSL.digest_ecdsa_sha1) - except: # noqa:E722 + except: sigVerifyPassed = False if sigVerifyPassed: # The signature check passed using SHA1 @@ -104,7 +104,7 @@ def verify(msg, sig, hexPubkey): try: return makePubCryptor(hexPubkey).verify( sig, msg, digest_alg=OpenSSL.EVP_sha256) - except: # noqa:E722 + except: return False