aboutsummaryrefslogtreecommitdiff
path: root/javascript/olm_post.js
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/olm_post.js')
-rw-r--r--javascript/olm_post.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/javascript/olm_post.js b/javascript/olm_post.js
index a3a3ef4..ad058d9 100644
--- a/javascript/olm_post.js
+++ b/javascript/olm_post.js
@@ -49,7 +49,7 @@ function account_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_account_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -81,7 +81,7 @@ Account.prototype['identity_keys'] = restore_stack(function() {
account_method(Module['_olm_account_identity_keys'])(
this.ptr, keys, keys_length
);
- return Pointer_stringify(keys);
+ return UTF8ToString(keys, keys_length);
});
Account.prototype['sign'] = restore_stack(function(message) {
@@ -104,7 +104,7 @@ Account.prototype['sign'] = restore_stack(function(message) {
message_array[i] = 0;
}
}
- return Pointer_stringify(signature_buffer);
+ return UTF8ToString(signature_buffer, signature_length);
});
Account.prototype['one_time_keys'] = restore_stack(function() {
@@ -115,7 +115,7 @@ Account.prototype['one_time_keys'] = restore_stack(function() {
account_method(Module['_olm_account_one_time_keys'])(
this.ptr, keys, keys_length
);
- return Pointer_stringify(keys);
+ return UTF8ToString(keys, keys_length);
});
Account.prototype['mark_keys_as_published'] = restore_stack(function() {
@@ -164,7 +164,7 @@ Account.prototype['pickle'] = restore_stack(function(key) {
key_array[i] = 0;
}
}
- return Pointer_stringify(pickle_buffer);
+ return UTF8ToString(pickle_buffer, pickle_length);
});
Account.prototype['unpickle'] = restore_stack(function(key, pickle) {
@@ -196,7 +196,7 @@ function session_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_session_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -228,7 +228,7 @@ Session.prototype['pickle'] = restore_stack(function(key) {
key_array[i] = 0;
}
}
- return Pointer_stringify(pickle_buffer);
+ return UTF8ToString(pickle_buffer, pickle_length);
});
Session.prototype['unpickle'] = restore_stack(function(key, pickle) {
@@ -320,7 +320,7 @@ Session.prototype['session_id'] = restore_stack(function() {
session_method(Module['_olm_session_id'])(
this.ptr, id_buffer, id_length
);
- return Pointer_stringify(id_buffer);
+ return UTF8ToString(id_buffer, id_length);
});
Session.prototype['has_received_message'] = function() {
@@ -396,7 +396,7 @@ Session.prototype['encrypt'] = restore_stack(function(
return {
"type": message_type,
- "body": UTF8ToString(message_buffer),
+ "body": UTF8ToString(message_buffer, message_length),
};
} finally {
if (random !== undefined) {
@@ -445,14 +445,14 @@ Session.prototype['decrypt'] = restore_stack(function(
0, "i8"
);
- return UTF8ToString(plaintext_buffer);
+ return UTF8ToString(plaintext_buffer, plaintext_length);
} finally {
if (message_buffer !== undefined) {
free(message_buffer);
}
if (plaintext_buffer !== undefined) {
// don't leave a copy of the plaintext in the heap.
- bzero(plaintext_buffer, max_plaintext_length + NULL_BYTE_PADDING_LENGTH);
+ bzero(plaintext_buffer, max_plaintext_length);
free(plaintext_buffer);
}
}
@@ -469,7 +469,7 @@ function utility_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_utility_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -501,7 +501,7 @@ Utility.prototype['sha256'] = restore_stack(function(input) {
input_array[i] = 0;
}
}
- return Pointer_stringify(output_buffer);
+ return UTF8ToString(output_buffer, output_length);
});
Utility.prototype['ed25519_verify'] = restore_stack(function(