Commit 4721eb4f authored by Valentin Samir's avatar Valentin Samir

Catch base64 decode error on b64decode to raise our custom exception BadHash

parent fbc977c6
......@@ -561,7 +561,10 @@ class LdapHashUserPassword(object):
elif scheme == b'{CRYPT}':
return b'$'.join(hashed_passord.split(b'$', 3)[:-1])[len(scheme):]
else:
hashed_passord = base64.b64decode(hashed_passord[len(scheme):])
try:
hashed_passord = base64.b64decode(hashed_passord[len(scheme):])
except TypeError as error:
raise cls.BadHash("Bad base64: %s" % error)
if len(hashed_passord) < cls._schemes_to_len[scheme]:
raise cls.BadHash("Hash too short for the scheme %s" % scheme)
return hashed_passord[cls._schemes_to_len[scheme]:]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment