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 * fixup: higher inner key data size limit
This commit is contained in:
parent
2730571966
commit
9ca666907b
2 changed files with 12 additions and 2 deletions
|
@ -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'
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue