diff options
author | Richard van der Hoff <richard@matrix.org> | 2016-05-20 12:35:59 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2016-05-24 13:40:21 +0100 |
commit | fa1e9446ac2b4d26dd592813ce0a372565df4c93 (patch) | |
tree | d236c87d22e5ac748f158b2a4ccb99c1951583d8 | |
parent | 173cbe112c139de0bd1a69dce5a03db360dc5abc (diff) |
Use _olm_unset instead of memset
memset is at risk of being optimised away, so use _olm_unset instead.
-rw-r--r-- | src/inbound_group_session.c | 7 | ||||
-rw-r--r-- | src/outbound_group_session.c | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/inbound_group_session.c b/src/inbound_group_session.c index b8f762d..6cded75 100644 --- a/src/inbound_group_session.c +++ b/src/inbound_group_session.c @@ -21,6 +21,7 @@ #include "olm/cipher.h" #include "olm/error.h" #include "olm/megolm.h" +#include "olm/memory.h" #include "olm/message.h" #include "olm/pickle.h" #include "olm/pickle_encoding.h" @@ -60,7 +61,7 @@ const char *olm_inbound_group_session_last_error( size_t olm_clear_inbound_group_session( OlmInboundGroupSession *session ) { - memset(session, 0, sizeof(OlmInboundGroupSession)); + _olm_unset(session, sizeof(OlmInboundGroupSession)); return sizeof(OlmInboundGroupSession); } @@ -85,7 +86,7 @@ size_t olm_init_inbound_group_session( _olm_decode_base64(session_key, session_key_length, key_buf); megolm_init(&session->initial_ratchet, key_buf, message_index); megolm_init(&session->latest_ratchet, key_buf, message_index); - memset(key_buf, 0, MEGOLM_RATCHET_LENGTH); + _olm_unset(key_buf, MEGOLM_RATCHET_LENGTH); return 0; } @@ -265,7 +266,7 @@ size_t olm_group_decrypt( plaintext, max_plaintext_length ); - memset(&tmp_megolm, 0, sizeof(tmp_megolm)); + _olm_unset(&tmp_megolm, sizeof(tmp_megolm)); if (r == (size_t)-1) { session->last_error = OLM_BAD_MESSAGE_MAC; return r; diff --git a/src/outbound_group_session.c b/src/outbound_group_session.c index fadf949..cf7d32c 100644 --- a/src/outbound_group_session.c +++ b/src/outbound_group_session.c @@ -22,6 +22,7 @@ #include "olm/cipher.h" #include "olm/error.h" #include "olm/megolm.h" +#include "olm/memory.h" #include "olm/message.h" #include "olm/pickle.h" #include "olm/pickle_encoding.h" @@ -63,7 +64,7 @@ const char *olm_outbound_group_session_last_error( size_t olm_clear_outbound_group_session( OlmOutboundGroupSession *session ) { - memset(session, 0, sizeof(OlmOutboundGroupSession)); + _olm_unset(session, sizeof(OlmOutboundGroupSession)); return sizeof(OlmOutboundGroupSession); } |