From 6694a8603305ab15cc11b9e983cedd4553a45277 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 12 Nov 2008 14:49:17 +0000 Subject: [PATCH] Backport: Apparently sparc64 is way more strict about uint16_t access alignment than I had thought: it gave bus errors when messing with var-cell headers. Maybe this patch will fix bug 862. svn:r17263 --- ChangeLog | 2 ++ src/or/buffers.c | 2 +- src/or/connection_or.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41437a4db..bafa2b8c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -48,6 +48,8 @@ Changes in version 0.2.0.32 - 2008-??-?? Bugfix on 0.2.0.x (??). - Remove the old v2 directory authority 'lefkada' from the default list. It has been gone for many months. + - Stop doing unaligned memory access that generated bus errors on + sparc64. Bugfix on 0.2.0.10-alpha. Fix for bug 862. o Minor bugfixes (controller): - Make DNS resolved events into "CLOSED", not "FAILED". Bugfix on diff --git a/src/or/buffers.c b/src/or/buffers.c index eb1be863a..b16091c30 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -966,7 +966,7 @@ fetch_var_cell_from_buf(buf_t *buf, var_cell_t **out, int linkproto) return 1; result = var_cell_new(length); result->command = command; - result->circ_id = ntohs(*(uint16_t*)hdr); + result->circ_id = ntohs(get_uint16(hdr)); buf_remove_from_front(buf, VAR_CELL_HEADER_SIZE); peek_from_buf(result->payload, length, buf); diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 00217f2dc..7d1231567 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -157,7 +157,7 @@ cell_unpack(cell_t *dest, const char *src) void var_cell_pack_header(const var_cell_t *cell, char *hdr_out) { - *(uint16_t*)(hdr_out) = htons(cell->circ_id); + set_uint16(hdr_out, htons(cell->circ_id)); *(uint8_t*)(hdr_out+2) = cell->command; set_uint16(hdr_out+3, htons(cell->payload_len)); }