1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 09:47:58 +00:00

use limited unpacker for outer key, fixes #2174 (#2790)

* use limited unpacker for outer key, fixes #2174

* fixup: higher inner key data size limit
This commit is contained in:
TW 2017-07-04 22:51:31 +02:00 committed by enkore
parent 2730571966
commit 9ca666907b
2 changed files with 12 additions and 2 deletions

View file

@ -597,7 +597,9 @@ def _load(self, key_data, passphrase):
return False
def decrypt_key_file(self, data, passphrase):
data = msgpack.unpackb(data)
unpacker = get_limited_unpacker('key')
unpacker.feed(data)
data = unpacker.unpack()
enc_key = EncryptedKey(internal_dict=data)
assert enc_key.version == 1
assert enc_key.algorithm == 'sha256'

View file

@ -169,8 +169,16 @@ def get_limited_unpacker(kind):
object_hook=StableDict,
unicode_errors='surrogateescape',
))
elif kind == 'key':
args.update(dict(use_list=True, # default value
max_array_len=0, # not used
max_map_len=10, # EncryptedKey dict
max_str_len=4000, # inner key data
object_hook=StableDict,
unicode_errors='surrogateescape',
))
else:
raise ValueError('kind must be "server", "client" or "manifest"')
raise ValueError('kind must be "server", "client", "manifest" or "key"')
return msgpack.Unpacker(**args)