summaryrefslogtreecommitdiff
path: root/lib/thandy/formats.py
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-03-19 12:03:04 -0400
committerNick Mathewson <nickm@torproject.org>2009-03-19 12:03:04 -0400
commit714d37da91c34db5911e413d53ab544f7ef5a9a3 (patch)
tree909b113215e49b8f4cb15872af76ad85a0a15a1d /lib/thandy/formats.py
parentce33821211c05735024617853aa3d0a31e63ef59 (diff)
Add lengths to the timestamp file.
This might break old clients, but AFAICT there are no clients running versions prior to 15 Dec. It's necessary to avoid some DOS attacks.
Diffstat (limited to 'lib/thandy/formats.py')
-rw-r--r--lib/thandy/formats.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/thandy/formats.py b/lib/thandy/formats.py
index b82bf05..5429d5c 100644
--- a/lib/thandy/formats.py
+++ b/lib/thandy/formats.py
@@ -794,19 +794,22 @@ def getBundleKey(bundlePath):
idx = bundlePath.rindex("/")
return bundlePath[:idx+1]
-def makeTimestampObj(mirrorlist_obj, keylist_obj,
+def makeTimestampObj(mirrorlist_obj, mirrorlist_len,
+ keylist_obj, keylist_len,
bundle_objs):
result = { '_type' : 'Timestamp',
'at' : formatTime(time.time()) }
result['m'] = [ mirrorlist_obj['ts'],
- formatHash(getDigest(mirrorlist_obj)) ]
+ formatHash(getDigest(mirrorlist_obj)),
+ mirrorlist_len ]
result['k'] = [ keylist_obj['ts'],
- formatHash(getDigest(keylist_obj)) ]
+ formatHash(getDigest(keylist_obj)),
+ keylist_len ]
result['b'] = bundles = {}
- for bundle in bundle_objs:
+ for bundle, bundleLen in bundle_objs:
k = getBundleKey(bundle['location'])
v = bundle['version']
- entry = [ v, bundle['location'], bundle['at'], formatHash(getDigest(bundle)) ]
+ entry = [ v, bundle['location'], bundle['at'], formatHash(getDigest(bundle)), bundleLen ]
if not bundles.has_key(k) or versionIsNewer(v, bundles[k][0]):
bundles[k] = entry