Megolm import: Fix handling of short files

Make sure we throw a sensible error when the body of the data is too short.
This commit is contained in:
Richard van der Hoff 2017-01-31 12:30:30 +00:00
parent 62c8c20268
commit c5f447260a
2 changed files with 11 additions and 1 deletions

View file

@ -50,7 +50,7 @@ export function decryptMegolmKeyFile(data, password) {
}
const ciphertextLength = body.length-(1+16+16+4+32);
if (body.length < 0) {
if (ciphertextLength < 0) {
throw new Error('Invalid file: too short');
}