[tor-commits] [bridgedb/master] Workaround for datetime exception in Stem for weird ed25519 certs.
isis at torproject.org
isis at torproject.org
Fri May 4 18:30:52 UTC 2018
commit 35772f8bca656f8ced14082c6e00b36345cd0332
Author: Isis Lovecruft <isis at torproject.org>
Date: Fri May 4 18:20:22 2018 +0000
Workaround for datetime exception in Stem for weird ed25519 certs.
There's few bridges whose ed25519 certificates contain the year 491869, which
the datetime module (called from Stem) believes "out of range". So instead
we'll parse the descriptors one at a time and catch the errors as we go.
* FIXES #26023: https://bugs.torproject.org/26023
---
bridgedb/parse/descriptors.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/bridgedb/parse/descriptors.py b/bridgedb/parse/descriptors.py
index 742f535..1b01023 100644
--- a/bridgedb/parse/descriptors.py
+++ b/bridgedb/parse/descriptors.py
@@ -161,7 +161,19 @@ def parseServerDescriptorsFile(filename, validate=True):
logging.info("Parsing server descriptors with Stem: %s" % filename)
descriptorType = 'server-descriptor 1.0'
document = parse_file(filename, descriptorType, validate=validate)
- routers = list(document)
+ routers = list()
+
+ # Work around https://bugs.torproject.org/26023 by parsing each descriptor
+ # at a time and catching any errors not handled in stem:
+ while True:
+ try:
+ routers.append(document.next())
+ except StopIteration:
+ break
+ except Exception as error:
+ logging.debug("Error while parsing a bridge server descriptor: %s"
+ % error)
+
return routers
def __cmp_published__(x, y):
More information about the tor-commits
mailing list