diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-11-07 16:09:58 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-11-08 16:44:50 -0500 |
commit | 49dd5ef3a3d1775fdc3c0a7d069d3097b3baeeec (patch) | |
tree | 7189ed200ae8f47bf7d3399d0b99243dc93bced3 /src/or/connection_or.c | |
parent | 758428dd32128874cefacc92ef63c1b5bc9a656e (diff) | |
download | tor-49dd5ef3a3d1775fdc3c0a7d069d3097b3baeeec.tar.gz tor-49dd5ef3a3d1775fdc3c0a7d069d3097b3baeeec.zip |
Add and use and unlikely-to-be-eliminated memwipe()
Apparently some compilers like to eliminate memset() operations on
data that's about to go out-of-scope. I've gone with the safest
possible replacement, which might be a bit slow. I don't think this
is critical path in any way that will affect performance, but if it
is, we can work on that in 0.2.4.
Fixes bug 7352.
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r-- | src/or/connection_or.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 6293fe881d..5eecee0740 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -1657,7 +1657,7 @@ or_handshake_state_free(or_handshake_state_t *state) crypto_digest_free(state->digest_received); tor_cert_free(state->auth_cert); tor_cert_free(state->id_cert); - memset(state, 0xBE, sizeof(or_handshake_state_t)); + memwipe(state, 0xBE, sizeof(or_handshake_state_t)); tor_free(state); } @@ -1698,7 +1698,7 @@ or_handshake_state_record_cell(or_handshake_state_t *state, this very often at all. */ cell_pack(&packed, cell); crypto_digest_add_bytes(d, packed.body, sizeof(packed.body)); - memset(&packed, 0, sizeof(packed)); + memwipe(&packed, 0, sizeof(packed)); } /** Remember that a variable-length <b>cell</b> has been transmitted (if @@ -1733,7 +1733,7 @@ or_handshake_state_record_var_cell(or_handshake_state_t *state, crypto_digest_add_bytes(d, buf, sizeof(buf)); crypto_digest_add_bytes(d, (const char *)cell->payload, cell->payload_len); - memset(buf, 0, sizeof(buf)); + memwipe(buf, 0, sizeof(buf)); } /** Set <b>conn</b>'s state to OR_CONN_STATE_OPEN, and tell other subsystems @@ -2090,7 +2090,7 @@ connection_or_send_auth_challenge_cell(or_connection_t *conn) connection_or_write_var_cell_to_buf(cell, conn); var_cell_free(cell); - memset(challenge, 0, sizeof(challenge)); + memwipe(challenge, 0, sizeof(challenge)); return 0; } |