Updated ValueError in addresses.py, updated safeGet & added exception handling for read permission error in helper_startup.py and reverted highlevelcrypto.py changes

This commit is contained in:
kuldeep.k@cisinlabs.com 2021-09-27 19:10:39 +05:30
parent a704b1a3b2
commit 3555f1d426
No known key found for this signature in database
GPG Key ID: AF4FB299BF7C7C2A
3 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -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()

View File

@ -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