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: for char in string:
num *= base num *= base
num += alphabet.index(char) num += alphabet.index(char)
except: # noqa:E722 # ValueError except ValueError:
# character not found (like a space character or a 0) # character not found (like a space character or a 0)
return 0 return 0
return num return num

View File

@ -49,13 +49,17 @@ def loadConfig():
'Loading config files from directory specified' 'Loading config files from directory specified'
' on startup: %s', state.appdata) ' on startup: %s', state.appdata)
else: else:
config.read(paths.lookupExeFolder() + 'keys.dat')
try: 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.') logger.info('Loading config files from same directory as program.')
needToCreateKeysFile = False needToCreateKeysFile = False
state.appdata = paths.lookupExeFolder() state.appdata = paths.lookupExeFolder()
except: # noqa:E722 else:
# Could not load the keys.dat file in the program directory. # Could not load the keys.dat file in the program directory.
# Perhaps it is in the appdata directory. # Perhaps it is in the appdata directory.
state.appdata = paths.lookupAppdataFolder() state.appdata = paths.lookupAppdataFolder()

View File

@ -95,7 +95,7 @@ def verify(msg, sig, hexPubkey):
# old SHA1 algorithm. # old SHA1 algorithm.
sigVerifyPassed = makePubCryptor(hexPubkey).verify( sigVerifyPassed = makePubCryptor(hexPubkey).verify(
sig, msg, digest_alg=OpenSSL.digest_ecdsa_sha1) sig, msg, digest_alg=OpenSSL.digest_ecdsa_sha1)
except: # noqa:E722 except:
sigVerifyPassed = False sigVerifyPassed = False
if sigVerifyPassed: if sigVerifyPassed:
# The signature check passed using SHA1 # The signature check passed using SHA1
@ -104,7 +104,7 @@ def verify(msg, sig, hexPubkey):
try: try:
return makePubCryptor(hexPubkey).verify( return makePubCryptor(hexPubkey).verify(
sig, msg, digest_alg=OpenSSL.EVP_sha256) sig, msg, digest_alg=OpenSSL.EVP_sha256)
except: # noqa:E722 except:
return False return False