aboutsummaryrefslogtreecommitdiffstats
path: root/matrix-e2e.c
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dave@treblig.org>2017-05-07 15:52:46 +0100
committerDr. David Alan Gilbert <dave@treblig.org>2018-02-25 02:08:49 +0000
commita5c49085eb4f47b7930f8b1c0b9ca827083eb4e5 (patch)
tree76b91760530648cd1be4363e958f6647c65508d8 /matrix-e2e.c
parent8795475df2c9192541412474588187a4031efd53 (diff)
downloadpurple-matrix-a5c49085eb4f47b7930f8b1c0b9ca827083eb4e5.tar.gz
e2e: Add clear_mem
We can't rely on having memset_s, so add our own equivalent that declares itself volatile. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
Diffstat (limited to 'matrix-e2e.c')
-rw-r--r--matrix-e2e.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/matrix-e2e.c b/matrix-e2e.c
index 71c1426..b2c3dd4 100644
--- a/matrix-e2e.c
+++ b/matrix-e2e.c
@@ -31,6 +31,21 @@ struct _MatrixE2EData {
gchar *device_id;
};
+/* Really clear an area of memory */
+static void clear_mem(volatile char *data, size_t len)
+{
+#ifdef __STDC_LIB_EXT1__
+ /* Untested! */
+ memset_s(data, len, '\0', len);
+#else
+ size_t index;
+ for(index = 0;index < len; index ++)
+ {
+ data[index] = '\0';
+ }
+#endif
+}
+
/* Sign the JsonObject with olm_account_sign and add it to the object
* as a 'signatures' member of the top level object.
* 0 on success