aboutsummaryrefslogtreecommitdiff
path: root/javascript/olm_sas.js
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2019-04-08 15:54:02 -0400
committerHubert Chathi <hubert@uhoreg.ca>2019-04-08 15:54:02 -0400
commitebc156e7c272e08e375c3e704651b179541e078b (patch)
treeca421f9d429f009e1c939bf96314fd4764ae241b /javascript/olm_sas.js
parent071029c20174307de28ca20232196f83fcc37763 (diff)
re-add null termination in javascript
because older versions of emscripten don't support the length argument to UTF8ToString.
Diffstat (limited to 'javascript/olm_sas.js')
-rw-r--r--javascript/olm_sas.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/javascript/olm_sas.js b/javascript/olm_sas.js
index a01cc07..5cf3fb0 100644
--- a/javascript/olm_sas.js
+++ b/javascript/olm_sas.js
@@ -28,7 +28,7 @@ SAS.prototype['free'] = function() {
SAS.prototype['get_pubkey'] = restore_stack(function() {
var pubkey_length = sas_method(Module['_olm_sas_pubkey_length'])(this.ptr);
- var pubkey_buffer = stack(pubkey_length);
+ var pubkey_buffer = stack(pubkey_length + NULL_BYTE_PADDING_LENGTH);
sas_method(Module['_olm_sas_get_pubkey'])(this.ptr, pubkey_buffer, pubkey_length);
return UTF8ToString(pubkey_buffer, pubkey_length);
});
@@ -66,7 +66,7 @@ SAS.prototype['calculate_mac'] = restore_stack(function(input, info) {
var info_array = array_from_string(info);
var info_buffer = stack(info_array);
var mac_length = sas_method(Module['_olm_sas_mac_length'])(this.ptr);
- var mac_buffer = stack(mac_length);
+ var mac_buffer = stack(mac_length + NULL_BYTE_PADDING_LENGTH);
sas_method(Module['_olm_sas_calculate_mac'])(
this.ptr,
input_buffer, input_array.length,
@@ -89,5 +89,5 @@ SAS.prototype['calculate_mac_long_kdf'] = restore_stack(function(input, info) {
info_buffer, info_array.length,
mac_buffer, mac_length
);
- return Pointer_stringify(mac_buffer);
+ return UTF8ToString(mac_buffer, mac_length);
});