aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuit.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-01-02 09:03:38 +0000
committerRoger Dingledine <arma@torproject.org>2004-01-02 09:03:38 +0000
commit53061b3778167a9c4968b12c6d60e43301af46b7 (patch)
tree6a0fa36cab54d2bef96c57da55e6701611c6de9d /src/or/circuit.c
parentc2e37901be4187bb209581bab31db0c305bb53cd (diff)
downloadtor-53061b3778167a9c4968b12c6d60e43301af46b7.tar
tor-53061b3778167a9c4968b12c6d60e43301af46b7.tar.gz
fix endian issue: rh.integrity was getting sent wrong
now it's a char[4] rather than an int svn:r966
Diffstat (limited to 'src/or/circuit.c')
-rw-r--r--src/or/circuit.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c
index 22a17fa9a..071c94726 100644
--- a/src/or/circuit.c
+++ b/src/or/circuit.c
@@ -314,14 +314,15 @@ int circuit_stream_is_being_handled(connection_t *conn) {
/* update digest from the payload of cell. assign integrity part to cell. */
static void relay_set_digest(crypto_digest_env_t *digest, cell_t *cell) {
- uint32_t integrity;
+ char integrity[4];
relay_header_t rh;
crypto_digest_add_bytes(digest, cell->payload, CELL_PAYLOAD_SIZE);
- crypto_digest_get_digest(digest, (char *)&integrity, 4);
- log_fn(LOG_DEBUG,"Putting digest of %u into relay cell.",integrity);
+ crypto_digest_get_digest(digest, integrity, 4);
+ log_fn(LOG_DEBUG,"Putting digest of %u %u %u %u into relay cell.",
+ integrity[0], integrity[1], integrity[2], integrity[3]);
relay_header_unpack(&rh, cell->payload);
- rh.integrity = integrity;
+ memcpy(rh.integrity, integrity, 4);
relay_header_pack(cell->payload, &rh);
}
@@ -330,29 +331,31 @@ static void relay_set_digest(crypto_digest_env_t *digest, cell_t *cell) {
* and cell to their original state and return 0.
*/
static int relay_digest_matches(crypto_digest_env_t *digest, cell_t *cell) {
- uint32_t received_integrity, calculated_integrity;
+ char received_integrity[4], calculated_integrity[4];
relay_header_t rh;
crypto_digest_env_t *backup_digest=NULL;
backup_digest = crypto_digest_dup(digest);
relay_header_unpack(&rh, cell->payload);
- received_integrity = rh.integrity;
- rh.integrity = 0;
+ memcpy(received_integrity, rh.integrity, 4);
+ memset(rh.integrity, 0, 4);
relay_header_pack(cell->payload, &rh);
- log_fn(LOG_DEBUG,"Reading digest of %u from relay cell.",received_integrity);
+ log_fn(LOG_DEBUG,"Reading digest of %u %u %u %u from relay cell.",
+ received_integrity[0], received_integrity[1],
+ received_integrity[2], received_integrity[3]);
crypto_digest_add_bytes(digest, cell->payload, CELL_PAYLOAD_SIZE);
- crypto_digest_get_digest(digest, (char *)&calculated_integrity, 4);
+ crypto_digest_get_digest(digest, calculated_integrity, 4);
- if(received_integrity != calculated_integrity) {
- log_fn(LOG_INFO,"Recognized=0 but bad digest. Not recognizing. (%d vs %d).",
- received_integrity, calculated_integrity);
+ if(memcmp(received_integrity, calculated_integrity, 4)) {
+ log_fn(LOG_INFO,"Recognized=0 but bad digest. Not recognizing.");
+// (%d vs %d).", received_integrity, calculated_integrity);
/* restore digest to its old form */
crypto_digest_assign(digest, backup_digest);
/* restore the relay header */
- rh.integrity = received_integrity;
+ memcpy(rh.integrity, received_integrity, 4);
relay_header_pack(cell->payload, &rh);
crypto_free_digest_env(backup_digest);
return 0;