diff options
author | Richard van der Hoff <richard@matrix.org> | 2016-12-15 13:37:34 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2016-12-15 13:37:34 +0000 |
commit | 8356fa37adbe1662141f93cc749e4c2d05af9f7b (patch) | |
tree | fdb7b236b0e3eb1ba33703495cf40d59dfec23b9 /javascript/olm_inbound_group_session.js | |
parent | 76610c0a3af57b600211ea38bc28bcccabc6a86c (diff) |
zero out plaintext buffers
Avoid leaving copies of the plaintext sitting around in the emscripten heap.
Diffstat (limited to 'javascript/olm_inbound_group_session.js')
-rw-r--r-- | javascript/olm_inbound_group_session.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/javascript/olm_inbound_group_session.js b/javascript/olm_inbound_group_session.js index 5815320..2e4727f 100644 --- a/javascript/olm_inbound_group_session.js +++ b/javascript/olm_inbound_group_session.js @@ -64,7 +64,7 @@ InboundGroupSession.prototype['create'] = restore_stack(function(session_key) { InboundGroupSession.prototype['decrypt'] = restore_stack(function( message ) { - var message_buffer, plaintext_buffer; + var message_buffer, plaintext_buffer, plaintext_length; try { message_buffer = malloc(message.length); @@ -80,7 +80,7 @@ InboundGroupSession.prototype['decrypt'] = restore_stack(function( plaintext_buffer = malloc(max_plaintext_length + NULL_BYTE_PADDING_LENGTH); var message_index = stack(4); - var plaintext_length = inbound_group_session_method( + plaintext_length = inbound_group_session_method( Module["_olm_group_decrypt"] )( this.ptr, @@ -105,6 +105,8 @@ InboundGroupSession.prototype['decrypt'] = restore_stack(function( free(message_buffer); } if (plaintext_buffer !== undefined) { + // don't leave a copy of the plaintext in the heap. + bzero(plaintext_buffer, plaintext_length + NULL_BYTE_PADDING_LENGTH); free(plaintext_buffer); } } |