Unverified Commit 02e40fa9 authored by Isis Lovecruft's avatar Isis Lovecruft
Browse files

Fix a potential bug where an OR ID might have been unprocessed base64.

 * CHANGE bridgedb.parse.networkstatus.parseRLine() to check the OR
   nickname validity only after parsing (and readding the base64 padding
   to) the OR ID digest.
 * ADD inline comments about why this is done.
parent 819fdce1
......@@ -103,18 +103,25 @@ def parseRLine(line):
"Wrong number of fields in networkstatus 'r'-line: %r" % line)
nickname, ID = fields[:2]
ID = parseUnpaddedBase64(ID)
except InvalidBase64 as error:
raise InvalidNetworkstatusRouterIdentity(error)
# Check the nickname validity after parsing the ID, otherwise, if the
# nickname is invalid, we end up with the nickname being ``None`` and
# the ID being unparsed, unpadded (meaning it is technically invalid)
# base64.
except NetworkstatusParsingError as error:
nickname, ID = None, None
except InvalidRouterNickname as error:
# Assume that we mostly care about obtaining the OR's ID, then it
# should be okay to set the nickname to ``None``, if it was invalid.
nickname = None
except InvalidNetworkstatusRouterIdentity as error:
Supports Markdown
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