Merge pull request #40 from matrix-org/rav/fix_encryption
Avoid buffer overrun on encryption
This commit is contained in:
commit
819f0d24db
2 changed files with 16 additions and 0 deletions
|
@ -83,6 +83,14 @@ OutboundGroupSession.prototype['encrypt'] = function(plaintext) {
|
||||||
plaintext_buffer, plaintext_length,
|
plaintext_buffer, plaintext_length,
|
||||||
message_buffer, message_length
|
message_buffer, message_length
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// UTF8ToString requires a null-terminated argument, so add the
|
||||||
|
// null terminator.
|
||||||
|
Module['setValue'](
|
||||||
|
message_buffer+message_length,
|
||||||
|
0, "i8"
|
||||||
|
);
|
||||||
|
|
||||||
return Module['UTF8ToString'](message_buffer);
|
return Module['UTF8ToString'](message_buffer);
|
||||||
} finally {
|
} finally {
|
||||||
if (plaintext_buffer !== undefined) {
|
if (plaintext_buffer !== undefined) {
|
||||||
|
|
|
@ -335,6 +335,14 @@ Session.prototype['encrypt'] = restore_stack(function(
|
||||||
random, random_length,
|
random, random_length,
|
||||||
message_buffer, message_length
|
message_buffer, message_length
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// UTF8ToString requires a null-terminated argument, so add the
|
||||||
|
// null terminator.
|
||||||
|
Module['setValue'](
|
||||||
|
message_buffer+message_length,
|
||||||
|
0, "i8"
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"type": message_type,
|
"type": message_type,
|
||||||
"body": Module['UTF8ToString'](message_buffer),
|
"body": Module['UTF8ToString'](message_buffer),
|
||||||
|
|
Loading…
Reference in a new issue