Show error if encodeAddress function is given a RIPE hash that is not 20 bytes long

This commit is contained in:
Jonathan Warren 2013-04-07 16:23:19 -04:00
parent adb6ea4b6c
commit 8000d7d733
1 changed files with 2 additions and 0 deletions

View File

@ -96,6 +96,8 @@ def calculateInventoryHash(data):
def encodeAddress(version,stream,ripe):
if version >= 2:
if len(ripe) != 20:
sys.stderr.write('Programming error in encodeAddress: The length of a given ripe hash was not 20.')
if ripe[:2] == '\x00\x00':
ripe = ripe[2:]
elif ripe[:1] == '\x00':